Skip to content

feat(preprod): Add PR comments for snapshot base-build edge cases#115460

Open
NicoHinderling wants to merge 2 commits into
masterfrom
feat/preprod-pr-comment-edge-cases
Open

feat(preprod): Add PR comments for snapshot base-build edge cases#115460
NicoHinderling wants to merge 2 commits into
masterfrom
feat/preprod-pr-comment-edge-cases

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented May 13, 2026

Align PR comment logic with status check logic for three base-build edge cases that previously caused the PR comment task to silently return:

  1. No base_sha (e.g. PR without a merge target) — now posts a comment showing uploaded snapshot counts with a message explaining diffs will appear once a base upload exists
  2. base_sha but no matching base build yet — posts a "Waiting for base snapshots..." comment that auto-updates within ~10 minutes
  3. Timeout (base never arrived) — posts "No base snapshots found" after the grace period expires

These three scenarios were already handled gracefully by the status check task (added in #115448). The PR comment task was the gap — it would hit the has_changes/has_failures gate and return without posting anything.

Changes:

  • snapshot_templates.py — Three new format functions (format_solo_snapshot_pr_comment, format_waiting_for_base_snapshot_pr_comment, format_missing_base_snapshot_pr_comment) sharing a _format_solo_comment helper and message constants. Extracted _format_settings_link to DRY the existing function.
  • snapshot_tasks.py (PR comment task) — Added is_solo detection before the has_changes/has_failures gate, routing to the correct template based on base_sha presence and whether this is a timeout invocation. The existing diff path moves into an else branch.
  • status_checks/snapshots/tasks.py — The waiting_for_base timeout block now also schedules a delayed create_preprod_snapshot_pr_comment_task with the same 600s countdown, so the PR comment updates to "missing base" if the base never arrives.

Builds on #115448 which added the grace period to the status check side.

Align PR comment logic with status check logic so that all three
base-build edge cases post comments instead of silently returning:
no base_sha posts "Generated N snapshots", missing base posts
"Waiting for base snapshots...", and timeout posts "No base
snapshots found".

Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 13, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review May 13, 2026 00:10
@NicoHinderling NicoHinderling requested a review from a team as a code owner May 13, 2026 00:10
Copy link
Copy Markdown
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 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9c9ea42. Configure here.

Comment thread src/sentry/preprod/vcs/pr_comments/snapshot_tasks.py
Comment thread src/sentry/preprod/vcs/pr_comments/snapshot_tasks.py
First-upload with base_sha would post "Waiting..." but no timeout was
scheduled, leaving the comment stuck. Now routes first uploads to the
solo comment like the status check does.

Also ensure existing "Waiting" comments get updated to the normal diff
view when base arrives with no changes, instead of silently returning.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
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