Skip to content

fix(#1470): retry review submission without inline comments on 422 - #1474

Closed
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1470-422-retry-graceful
Closed

fix(#1470): retry review submission without inline comments on 422#1474
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1470-422-retry-graceful

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

When CreatePullRequestReview returns a 422 Unprocessable Entity error and inline comments were attached, the error is likely caused by stale or invalid diff positions. Instead of failing the entire review run, retry the submission without inline comments so the formal review disposition (APPROVE/REQUEST_CHANGES) is still recorded. A warning is logged noting the dropped inline comments.

The retry only triggers when both conditions are met:

  • The error is a GitHub API 422
  • Inline comments were present in the failed request

Non-422 errors and 422 errors without inline comments propagate unchanged, preserving existing behavior for other failure modes.

Also adds CreatePullRequestReviewFunc to FakeClient for per-call error control in tests.


Closes #1470

Post-script verification

  • Branch is not main/master (agent/1470-422-retry-graceful)
  • Secret scan passed (gitleaks — 4342f307b57386cde8b751fe1a1a9002ea7fabde..HEAD)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

When CreatePullRequestReview returns a 422 Unprocessable Entity error
and inline comments were attached, the error is likely caused by stale
or invalid diff positions. Instead of failing the entire review run,
retry the submission without inline comments so the formal review
disposition (APPROVE/REQUEST_CHANGES) is still recorded. A warning is
logged noting the dropped inline comments.

The retry only triggers when both conditions are met:
- The error is a GitHub API 422
- Inline comments were present in the failed request

Non-422 errors and 422 errors without inline comments propagate
unchanged, preserving existing behavior for other failure modes.

Also adds CreatePullRequestReviewFunc to FakeClient for per-call
error control in tests.

Closes #1470
@github-actions

Copy link
Copy Markdown

Site preview

Preview: https://136b2a4d-site.fullsend-ai.workers.dev

Commit: 51725293b6b480ac2128a5898b54b517ec019fda

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [style] internal/forge/fake.go:148CreatePullRequestReviewFunc is invoked while f.mu is held (see CreatePullRequestReview at line 846). The doc comment should warn that callbacks must not call other FakeClient methods, as sync.Mutex is not reentrant and such calls would deadlock. The current test is safe (direct field access), but future test authors may not realize the constraint.
    Remediation: Add a note to the doc comment: "The callback runs under f.mu — do not call other FakeClient methods from within it."

No blocking findings. The retry logic is correct: is422 properly unwraps via errors.As, the retry triggers only when both a 422 status and inline comments are present, and all other error paths propagate unchanged. Test coverage is thorough — happy-path retry, 422-without-comments, non-422 errors, and the is422 helper with wrapped/nil cases are all exercised.

Comment thread internal/forge/fake.go
// Pull request reviews for ListPullRequestReviews.
PRReviews map[string][]PullRequestReview // key: "owner/repo/number"

// CreatePullRequestReviewFunc, when non-nil, overrides the default

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] style

CreatePullRequestReviewFunc is invoked while f.mu is held. The doc comment should warn that callbacks must not call other FakeClient methods, as sync.Mutex is not reentrant and such calls would deadlock.

Suggested fix: Add a note to the doc comment: "The callback runs under f.mu — do not call other FakeClient methods from within it."

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label May 26, 2026
@ralphbean
ralphbean requested a review from ascerra May 26, 2026 18:44
@rh-hemartin

Copy link
Copy Markdown
Member

I dont think this is worth pursuing, the real fix is to cancel previous reviews when one is incoming. We may need a debounce system as the one proposed for retro in one of the PRs currently open.

@rh-hemartin rh-hemartin closed this Jun 8, 2026
@fullsend-ai-retro

Copy link
Copy Markdown

Retro: PR #1474 — Closed without merge (symptom-level fix for already-fixed problem)

Timeline

  1. 2026-05-26 08:05 — Retro agent filed #1470 about 422 errors when submitting inline review comments, proposing a retry-without-comments approach.
  2. 2026-05-26 08:10 — Triage agent labeled it ready-to-code.
  3. 2026-05-26 08:18 — Code agent opened PR #1474 with a single commit implementing retry logic in submitFormalReview().
  4. 2026-05-26 08:24 — Review agent approved with one low-severity style note.
  5. 2026-05-26 18:44 — Human (ralphbean) requested human review.
  6. 2026-06-08 08:03 — Human (rh-hemartin) closed without merging, stating the real fix is to cancel stale reviews via a debounce system, not to retry failed submissions.

Root cause of wasted work

The retro agent filed #1470 as a near-duplicate of the still-open #1067, which describes the same 422 error in the same function (submitFormalReview) with the same proposed fix (retry without inline comments). Worse, PR #1348 had already shipped a fix for #1067 (diff-hunk validation before submission), but #1067 was never closed. The retro agent also filed #1349 specifically to close #1067, but that too remains open. The entire pipeline (triage → code → review) ran on a near-duplicate issue for an already-fixed problem.

Existing issues that cover the identified gaps

All improvement areas from this workflow are already tracked:

  • Retro dedup failure#1948 (broader related-issue search before proposing)
  • Recurrence tracking#1847 (comment on existing issues when same problem recurs)
  • Review agent strategic fitness#849 (evaluate root-cause vs workaround, flag alternative approaches)
  • Review debounce/stale cancellation#1418, #1422, #1331, #981

Housekeeping note

#1067 is still open with ready-to-code label despite being fixed by PR #1348. A code agent could be dispatched on it at any time, wasting more tokens. #1349 was filed to close it but hasn't been acted upon. Both should be closed.

No new proposals filed — all gaps are covered by existing open issues.

@github-actions
github-actions Bot deleted the agent/1470-422-retry-graceful branch June 28, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-review script should handle 422 errors from invalid diff positions gracefully

1 participant