Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Jan 23, 2026

This is a follow-up to #106567 which fixes the issue we found in SENTRY-5H53.

Description

This PR adds the extract_github_info() function to extract GitHub metadata from webhook events for improved debugging and logging.

In the future, we should also add this ability to Seer's code review code path.

Changes

New Function: extract_github_info()

  • Extracts GitHub metadata from webhook event payloads
  • Returns a dictionary with:
    • github_owner: Repository owner/organization name
    • github_repo_name: Repository name
    • github_repo_full_name: Full repository name (owner/repo)
    • github_event_url: URL to the specific event (check_run, pull_request, or comment)

Integration

  • Updated handle_webhook_event() in handlers.py to use extract_github_info()
  • Extracted metadata is passed as extra parameter to event handlers
  • Updated check_run.py, issue_comment.py, and pull_request.py to accept extra parameter

Testing

  • Added comprehensive unit test suite with 14 test cases
  • Tests cover all event types (pull_request, check_run, issue_comment)
  • Tests verify URL precedence logic (comment > check_run > pull_request)
  • Tests use real GitHub webhook fixtures for better accuracy
  • Edge cases tested (missing data, empty events, etc.)

Fixtures

  • Updated GitHub fixtures to include complete repository metadata
  • Added missing repository.name and repository.owner.login fields

Fixes CW-299

@armenzg armenzg self-assigned this Jan 23, 2026
@linear
Copy link

linear bot commented Jan 23, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 23, 2026
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


action = event.get("action")
# We can use html_url to search through the logs for this event.
extra = {"html_url": event.get("check_run", {}).get("html_url"), "action": action}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent enum-to-string conversion for Celery task parameter

Low Severity

The process_github_webhook_event task was updated to expect github_event: str, and schedule_task now explicitly passes github_event.value with a comment about Celery serialization. However, the call in check_run.py still passes github_event (the GithubWebhookType enum) directly without converting to .value. While this works at runtime because StrEnum members are strings, it creates an inconsistency that contradicts the explicit conversion pattern established elsewhere.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants