Skip to content

Post-review.sh should retry on transient GitHub API errors when submitting formal PR reviews #159

Description

@fullsend-ai-retro

What happened

On PR #148, the merge queue ejected the PR because the 001-clean-approve review eval case failed. The review agent performed correctly — it approved, posted a thorough comment (scored 5/5 on review_quality), and stayed within cost/turn limits. But post-review.sh received a 422 Unprocessable Entity from the GitHub API when submitting the formal PR review to the ephemeral fixture repo (halfsend/eval-001-clean-approve-1400fa2d). This caused post-review.sh to exit 1, which meant the ready-for-merge label was never applied. The required_labels judge then failed because ready-for-merge was absent. The human had to diagnose the root cause from CI logs, post a detailed analysis, and re-queue the PR, adding ~45 minutes to merge time.

What could go better

The human noted this is not just an eval concern: 'If post-review.sh fails hard on a 422, the same thing will happen in production: a valid review gets posted as a comment but the label never lands, so the PR sits unmerged. That needs separate follow-up (error handling / retry in post-review.sh).' The 422 can occur when the PR is in a transitional state (e.g., just created, merging, or when the head SHA changes during the review submission window). No existing issue covers this failure mode. Confidence is high — the human's analysis is credible and the fix is straightforward.

Proposed change

Add retry logic with backoff to the formal PR review submission step in scripts/post-review.sh. Specifically: (1) wrap the gh api or gh pr review call that submits the formal review in a retry loop (max 3 attempts with 5-second/15-second backoff), (2) on 422, log the response body for debugging and retry, (3) if all retries are exhausted but the review comment was already posted successfully, attempt to apply the ready-for-merge label directly as a degraded-mode fallback, (4) include the HTTP status code and response body in the error message for diagnosability. This improves both eval reliability (no false eval failures from transient API errors) and production reliability (reviews don't silently fail to trigger merge labels).

Validation criteria

When post-review.sh encounters a 422 on formal PR review submission: (1) it retries up to 3 times with backoff, (2) retry attempts are logged with the response body, (3) if retries succeed, the label is applied normally, (4) if retries are exhausted but the comment was posted, it attempts to apply the label directly. Unit test: add a test case to scripts/post-review-test.sh that mocks a 422 response and verifies the retry behavior.


Generated by retro agent from #148

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-for-triageTriggers triage agent dispatchready-to-codeTriggers code agent dispatch

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions