feat(preprod): Add size_analysis webhook resource and broadcasting#110196
Open
cameroncooke wants to merge 4 commits intomasterfrom
Open
feat(preprod): Add size_analysis webhook resource and broadcasting#110196cameroncooke wants to merge 4 commits intomasterfrom
cameroncooke wants to merge 4 commits intomasterfrom
Conversation
Add webhook infrastructure for size analysis notifications: - SizeAnalysisActionType with COMPLETED action - SIZE_ANALYSIS resource type and event expansion - SIZE_ANALYSIS_COMPLETED event type in metrics enum - size_analysis -> project:read in required permissions - organizations:preprod-size-analysis-webhooks feature flag
…t calls - New webhooks.py module with payload builder and send_size_analysis_webhook helper - Webhook fires at terminal states: standalone success, PR comparison success/failure, build config mismatch, and analysis failure - Feature-flag gated behind organizations:preprod-size-analysis-webhooks - Payload includes buildId, status, sizes, comparison data, git context, and app metadata
Tests cover: - Payload construction for all scenarios: standalone success, PR comparison success/failure, analysis failure, error codes, NOT_RAN/PENDING/PROCESSING - Feature flag gating - Broadcast exception handling - Platform/artifact type mapping - App metadata and git context population
…ok payload Order comparison records by date_added descending when building the webhook payload, ensuring the most recent comparison is used when multiple exist for the same head metric.
4 tasks
Contributor
There was a problem hiding this comment.
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.
| send_size_analysis_webhook(artifact=artifact, organization_id=self.organization.id) | ||
|
|
||
| mock_broadcast.delay.assert_called_once() | ||
| call_kwargs = mock_broadcast.delay.call_kwargs |
Contributor
There was a problem hiding this comment.
Dead store from accidentally committed debugging code in test
Low Severity
Line 357 assigns call_kwargs = mock_broadcast.delay.call_kwargs, which accesses a non-existent .call_kwargs attribute on a Mock (Mock silently returns a new Mock for any attribute). This value is immediately overwritten on line 359 with the correct .call_args. The comment on line 358 ("Use call_args since .delay is a mock") confirms this was a debugging artifact that wasn't cleaned up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Adds webhook support for the size analysis product within Sentry's pre-production platform. When size analysis reaches a terminal state (success or error), subscribed Sentry Apps receive a
size_analysis.completedwebhook with a lean payload containing build ID, status, sizes, comparison data, git context, and app metadata. Consumers use thebuildIdto fetch full details via the public API.Follows patterns established by the Seer webhook implementation (PR #96222) and reuses the existing
broadcast_webhooks_for_organizationinfrastructure — no new webhook plumbing needed.Changes
SizeAnalysisActionType(COMPLETED),SIZE_ANALYSISresource type, event expansion,SIZE_ANALYSIS_COMPLETEDmetrics enum,size_analysis → project:readpermissionorganizations:preprod-size-analysis-webhooks(FLAGPOLE, not api_exposed)src/sentry/preprod/size_analysis/webhooks.pywithbuild_webhook_payload()andsend_size_analysis_webhook()commit_comparison) — success withcomparison: nullcomparison: nullerrorCode/errorMessageDesign doc
See
src/sentry/preprod/size_analysis/WEBHOOK_DESIGN.mdfor full payload specification, examples, and rationale.Known limitation
When a PR build (head) is uploaded before its base branch build exists, the webhook fires with
comparison: null. If the base build arrives later and a comparison is created retroactively, the head artifact does not receive an updated webhook. This is acceptable for v1 because:buildIdif neededCompanion PRs
static/andsrc/)sentry-docsrepoTest plan
tests/sentry/preprod/size_analysis/test_webhooks.py)