feat(preprod): Add only-if-diff toggle for snapshot PR comments (EME-1046)#114035
Merged
runningcode merged 2 commits intomasterfrom Apr 28, 2026
Merged
feat(preprod): Add only-if-diff toggle for snapshot PR comments (EME-1046)#114035runningcode merged 2 commits intomasterfrom
runningcode merged 2 commits intomasterfrom
Conversation
…1046) Adds a second per-project option, sentry:preprod_snapshot_pr_comments_only_if_diff (default False). When enabled, the snapshot PR comment task short-circuits before posting if the comparison reports no changes for any sibling artifact on the PR. Existing comments from prior runs are left in place. Backend slice; frontend toggle ships in a follow-up PR.
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.
Reviewed by Cursor Bugbot for commit 7c52316. Configure here.
When the only-if-diff toggle is enabled, the early-return checked `not any(changes_map.values())`. `build_changes_map` only populates entries for SUCCESS comparisons, so when comparisons fail the map is empty and the failure comment is silently dropped — even though `compare_snapshots` enqueues this task on its failure path and the template renders a meaningful row for FAILED state. Also check `comparisons_map` for FAILED entries so the comment is still posted to surface the failure.
cameroncooke
approved these changes
Apr 28, 2026
| logger = logging.getLogger(__name__) | ||
|
|
||
| ENABLED_OPTION_KEY = "sentry:preprod_snapshot_pr_comments_enabled" | ||
| ONLY_IF_DIFF_OPTION_KEY = "sentry:preprod_snapshot_pr_comments_only_if_diff" |
Contributor
There was a problem hiding this comment.
I see we have this constant but we also have multiple places that use the key inline, though I can see we're just following the existing pattern so don't think we need to do anything. Maybe a future improvement would be to use a global constant as a single source of truth for these values.
3 tasks
cleptric
pushed a commit
that referenced
this pull request
May 5, 2026
…1046) (#114035) ## What Adds a second per-project option, `sentry:preprod_snapshot_pr_comments_only_if_diff` (default `False`), surfaced as `preprodSnapshotPrCommentsOnlyIfDiff` on the project details API. When enabled, `create_preprod_snapshot_pr_comment_task` short-circuits before posting if the comparison reports no changes across any sibling artifact for the PR. ## Why EME-1046. Today the only knob is "PR comments on/off". Some teams want the comment to appear only when there is something interesting to look at, so they can keep PR comments enabled by default without flooding no-op PRs.
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.

What
Adds a second per-project option,
sentry:preprod_snapshot_pr_comments_only_if_diff(defaultFalse), surfaced aspreprodSnapshotPrCommentsOnlyIfDiffon the project details API. When enabled,create_preprod_snapshot_pr_comment_taskshort-circuits before posting if the comparison reports no changes across any sibling artifact for the PR.Why
EME-1046. Today the only knob is "PR comments on/off". Some teams want the comment to appear only when there is something interesting to look at, so they can keep PR comments enabled by default without flooding no-op PRs.