bug(review): a superseded run aborts SubmitMany and strands its sibling reviews
Summary
SubmitMany (batch review submit) aborts the entire submission the moment any single run errors. If one run in the batch was superseded to failed by a concurrent new-commit trigger, submitting the original batch strands the valid sibling reviews — permanently, with no recovery path. This contradicts the function's own documented invariant.
Where
backend/internal/service/review/review.go, SubmitMany:
// Delivery is scoped to the runs in this submission, so a missing/stuck result
// for another PR in the same trigger cannot block feedback.
func (s *Service) SubmitMany(...) (...) {
...
for _, review := range reviews {
run, err := s.submitOne(ctx, workerID, review)
if err != nil {
return nil, err // aborts the whole batch
}
runs = append(runs, run)
}
...
delivered, err := s.deliverSubmitted(ctx, workerID, runs) // never reached
submitOne returns an error for a run that is no longer running (its default/terminal case: "review run %q is not running"). A run that SupersedeStaleRunningReviewRuns moved to failed hits exactly that branch.
Why it's wrong
The doc comment guarantees a stuck/stale result for one PR cannot block feedback for the others. But because submitOne mutates the store as it goes (a running run is written to complete) and SubmitMany aborts on the first error before delivery, a single superseded run blocks delivery of every valid sibling.
Repro
- A trigger creates a 2-PR batch:
run-A(PR-A) andrun-B(PR-B), both running, samebatch_id. - The worker pushes a new commit to PR-B; a fresh trigger fires
SupersedeStaleRunningReviewRuns, markingrun-Bfailed. - The reviewer submits both results in one
ao review submit --reviews -call. submitOne(run-A)succeeds (→complete);submitOne(run-B)returns"review run ... is not running";SubmitManyreturns the error → HTTP 422.run-Ais left complete-but-undelivered — the worker is never told about PR-A's requested changes. Becauserun-Bstaysfailed, every reviewer retry re-produces the 422, so PR-A's feedback is stranded permanently.
Suggested fix
Distinguish "run is no longer running (superseded/terminal)" from genuine input errors, and have SubmitMany skip the superseded run and keep delivering the valid siblings, instead of aborting. Genuine input errors (bad verdict, empty body, unknown run, wrong worker, verdict conflict) should still abort.
I would like to work on this.
Plan: add a regression for one valid review run plus a sibling superseded to terminal state, preserve rejection for genuine validation/ownership errors, and ensure the valid sibling is still delivered. I will keep the change scoped to the review service and its existing tests.
May I take this issue?
Assigned to @codebanditssss
the issue is still reproducible on current main: superseded or cancelled runs are terminal, and SubmitMany aborts before delivering valid sibling results. i opened #5460 with a focused fix and regression coverage. the change skips only stale terminal runs, keeps genuine validation errors fail-fast, and rejects submissions where every run is stale. focused tests, review-engine tests, controller tests, vet, linter, and diff checks pass; the repository-wide test run is currently affected by unrelated watcher/storage filesystem failures.