-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat(code_review): Improve debuggability #106567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… 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)
There was a problem hiding this 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.
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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):
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()github_owner: Repository owner/organization namegithub_repo_name: Repository namegithub_repo_full_name: Full repository name (owner/repo)github_event_url: URL to the specific event (check_run, pull_request, or comment)Integration
handle_webhook_event()inhandlers.pyto useextract_github_info()extraparameter to event handlerscheck_run.py,issue_comment.py, andpull_request.pyto acceptextraparameterTesting
Fixtures
repository.nameandrepository.owner.loginfieldsFixes CW-299