Skip to content

GH-4520: fix(autopilot): remove vestigial AutoReview self-approve — guaranteed 422 API call on every merge#4522

Merged
alekspetrov merged 1 commit into
mainfrom
pilot/GH-4520
Jul 23, 2026
Merged

GH-4520: fix(autopilot): remove vestigial AutoReview self-approve — guaranteed 422 API call on every merge#4522
alekspetrov merged 1 commit into
mainfrom
pilot/GH-4520

Conversation

@alekspetrov

Copy link
Copy Markdown
Collaborator

Summary

Automated PR created by Pilot for task GH-4520.

Closes #4520

Changes

GitHub Issue GH-4520: fix(autopilot): remove vestigial AutoReview self-approve — guaranteed 422 API call on every merge

Context

Every auto-merge logs auto-review failed … 422 "Review Can not approve your own pull request" (seen on pilot PRs 4514/4515/4516/4518 and console PR 30 on 2026-07-23 alone). The daemon tries to submit an APPROVE review on a PR authored by its own token — GitHub always rejects this with 422.

Root cause (ground truth @ main)

  • internal/autopilot/types.go:103-104AutoReview bool config field; :424 defaults it to true.
  • internal/autopilot/auto_merger.go:62-67MergePR calls approvePR when AutoReview is set; the error is swallowed as a WARN and merge proceeds.
  • The comment at auto_merger.go:51 states approval is obtained upstream by the controller's handleAwaitApproval before MergePR is called — the auto-review is vestigial. Net effect: one guaranteed-fail GitHub API call per merged PR on the shared 5000/hr user pool.

Required changes

  1. Delete the AutoReview config field, its default, and the approvePR call path in MergePR (including approvePR itself if nothing else references it).
  2. Keep loading configs that still contain auto_review: without erroring (lax YAML decode already handles unknown keys — verify).

Acceptance criteria

  • AC1: MergePR performs no review-submission API call.
  • AC2: A config file containing auto_review: true still loads (ignored, no error).
  • AC3: Existing merge-path tests pass; remove/adjust any test asserting the auto-review call.

Scope

internal/autopilot/types.go, internal/autopilot/auto_merger.go + tests. No behavior change to the approval-gate flow (handleAwaitApproval).

MergePR submitted an APPROVE review on PRs authored by the daemon's own
token, which GitHub always rejects with 422 (bot can't approve its own
PR). Approval is already obtained upstream via handleAwaitApproval before
MergePR runs, so the call was pure dead weight — one guaranteed-fail API
call against the shared rate-limit pool on every merge.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@alekspetrov
alekspetrov merged commit 6e5560b into main Jul 23, 2026
5 checks passed
@alekspetrov
alekspetrov deleted the pilot/GH-4520 branch July 23, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(autopilot): remove vestigial AutoReview self-approve — guaranteed 422 API call on every merge

2 participants