-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(code_review): Centralized config, prevent Seer calls and better types #105537
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
| assert event_payload is not None | ||
| option_key = EVENT_TYPE_TO_OPTION.get(event_type) | ||
| if option_key and not options.get(option_key): | ||
| return |
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.
Inverted option check blocks Seer calls incorrectly
The condition in call_seer_if_allowed is inverted. According to the comment in defaults.py ("Control forwarding of specific GitHub webhook types to overwatch (True) or seer (False)"), when the option is True the event should go to Overwatch (not Seer), and when False it should go to Seer. However, the current logic if option_key and not options.get(option_key): return returns early when the option is False, which is the opposite of the intended behavior. With default values set to True, all events will incorrectly be forwarded to Seer when they should be blocked.
| # Type checks to ensure the functions match WebhookProcessor protocol | ||
| _type_checked_handle_other_webhook_event: WebhookProcessor = handle_other_webhook_event | ||
| _type_checked_handle_check_run_event: WebhookProcessor = handle_check_run_event | ||
| schedule_task(event_type=event_type, event_payload=event) |
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.
Webhook payload transformation removed, raw events sent to Seer
The old handle_other_webhook_event function called _transform_webhook_to_codegen_request to convert raw GitHub webhook payloads into the CodecovTaskRequest format expected by Seer (with data, external_owner_id, request_type, organization_id fields). The new handle_webhook_event function passes the raw event payload directly to schedule_task without any transformation. For ISSUE_COMMENT, PULL_REQUEST, PULL_REQUEST_REVIEW, and PULL_REQUEST_REVIEW_COMMENT events, Seer will now receive raw GitHub webhook payloads in the wrong format. The transformation function also filtered non-PR-related events (returning None), which is also lost.
suejung-sentry
left a comment
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.
these changes make sense to me. guessing this one will get merged first
Refactor webhook event handling for Seer code review
Summary:
Consolidates webhook event type handling by replacing the custom
EventTypeenum with the existingGithubWebhookTypeenum and centralizing configuration.Changes:
EventTypeenum withGithubWebhookTypethroughout codebase for consistency with GitHub integration typeswebhooks/config.pyto centralize:EVENT_TYPE_TO_OPTION)EVENT_TYPE_TO_CUSTOM_HANDLER)EVENT_TYPE_TO_PROCESSOR)schedule_task()function for default webhook schedulingcall_seer_if_allowed()to check options before forwarding to Seerdefaults.py(moved webhook options near coding workflows section)webhook_forwarder.pyand webhook handlers viaEVENT_TYPE_TO_OPTIONBenefits: