Repository navigation
fix(hooks): check the PR the merge command actually targets - #3868
Merged
Merged
Conversation
The `gh pr merge` review guard always ran
`coderabbit_addressor.py --check` with no arguments, which resolves "the
PR for the current branch of the current checkout". It ignored both the
PR number and the `--repo` in the command it was inspecting.
Two consequences:
1. Merging a sibling project's PR (`gh pr merge N --repo OWNER/NAME`)
was judged against the wrong repository entirely.
2. When the current branch had no PR of its own, the addressor exited 2
("no PR found for current branch") and the hook treated that as a
block — so a perfectly reviewed merge was refused because of unrelated
local state. Hit in practice merging FastLED/fbuild#1268 while this
checkout sat on master.
Fixes both:
- The hook now parses the target PR number and repo out of the merge
command — bare number, `--repo`/`-R` in either order, `--repo=VALUE`,
and PR URLs (which carry their own owner/repo, so they no longer fall
back to the current checkout) — and forwards them.
- `coderabbit_addressor.py` gains `--repo OWNER/NAME`, which overrides
the slug used for the GitHub API calls. It requires an explicit PR
number, since "the PR for the current branch" is meaningless across
repositories.
- Exit 2 from the addressor means "could not identify a PR", not "this
PR has unresolved reviews". That now allows the merge with a warning
instead of blocking; only a real unresolved-comment verdict (exit 1)
blocks. The guard exists to protect review state, and where there is
no identifiable PR there is no review state to protect.
Verified against the live case: `coderabbit_addressor.py 1268 --check
--repo FastLED/fbuild` now correctly reports no unresolved comments.
New tests cover all six command shapes plus non-merge commands.
`pytest ci/tests/test_check_pr_merge_reviews.py`: 7 passed. `bash lint`
clean.
Co-Authored-By: Claude <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe merge hook now identifies pull request and repository targets from ChangesMerge review targeting
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant GitHubCLI
participant check_pr_merge_reviews
participant coderabbit_addressor
GitHubCLI->>check_pr_merge_reviews: Run gh pr merge
check_pr_merge_reviews->>check_pr_merge_reviews: Extract PR and repository
check_pr_merge_reviews->>coderabbit_addressor: Run --check with target
coderabbit_addressor-->>check_pr_merge_reviews: Return exit status
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
gh pr mergereview guard (ci/hooks/check_pr_merge_reviews.py) rancoderabbit_addressor.py --checkwith no arguments, which resolves "the PR for the current branch of the current checkout". It ignored both the PR number and the--repoin the command it was inspecting.Two consequences:
gh pr merge N --repo OWNER/NAME) was judged against this checkout instead ofOWNER/NAME.no PR found for current branch— and the hook treated that as a block. A fully reviewed merge was refused because of unrelated local state.Hit in practice while merging FastLED/fbuild#1268 with this checkout sitting on
master: the guard refused, even though that PR had 0 actionable CodeRabbit comments and 5/5 pre-merge checks passed. Neither documented override (FL_HOOK_SKIP=1,FL_HOOK_SOFT=1) reaches the hook's shell, so there was no way through short of reshaping the command to evade the guard — which is exactly what a guard shouldn't force.Fix
--repo/-Rin either order,--repo=VALUE, and PR URLs. URLs carry their own owner/repo, so they no longer silently fall back to the current checkout — that was a bug in my first cut of this change, caught by the table test below.coderabbit_addressor.pygains--repo OWNER/NAME, overriding the slug used for the API calls. It requires an explicit PR number, since "the PR for the current branch" is meaningless across repositories.This is strictly a targeting fix. A merge with genuinely unresolved CodeRabbit threads still blocks exactly as before.
Validation
Live case, which previously failed:
Guard rail still holds:
New tests cover all six command shapes plus non-merge commands (
gh pr view,gh pr createmust not engage the guard).pytest ci/tests/test_check_pr_merge_reviews.py→ 7 passedbash lint→ cleanFound while working #3867 / FastLED/fbuild#1267.
🤖 Generated with Claude Code
Summary by CodeRabbit