Skip to content

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Jan 20, 2026

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 20, 2026
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 20, 2026
@linear
Copy link

linear bot commented Jan 20, 2026

… debugging

- Add extract_github_info() function to extract GitHub metadata from webhook events
- Returns github_owner, github_repo_name, github_repo_full_name, and github_event_url
- Update handlers.py to use extract_github_info for structured logging
- Pass extracted metadata as 'extra' parameter to event handlers
- Add comprehensive unit tests with 14 test cases covering:
  - Pull request, check run, and issue comment events
  - URL precedence logic (comment > check_run > pull_request)
  - Edge cases (missing data, empty events, etc.)
- Update GitHub fixtures to include complete repository metadata
- Tests use real GitHub webhook fixtures for better accuracy
- Add explicit type annotation to result dict in extract_github_info()
- Add missing 'extra' parameter to _add_eyes_reaction_to_comment test calls
- Fix mock setup bug in test_logs_exception_on_api_error (mock_installation vs mock_integration)
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.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm just adding some missing data in these fixtures.


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
Member Author

Choose a reason for hiding this comment

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

extra is already being used by the logger, thus, no more changes are needed in this file.

"""
# The extracted important key values are used for debugging with logs
extra = extract_github_info(event)
extra["organization_slug"] = organization.slug
Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, we only have a couple of keys to filter-by.

Here's a screenshot using these kind of keys on Sentry Logs (link):

Image

@armenzg armenzg marked this pull request as ready for review January 20, 2026 17:32
@armenzg armenzg requested a review from a team as a code owner January 20, 2026 17:32
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