Repository navigation
fix(ci): resolve autofix threads with the maintainer token - #997
Conversation
GITHUB_TOKEN can reply to a review thread but not resolve it ("Resource
not accessible by integration"), so every fixed thread stayed open,
and the next round staged it again and answered it a second time as
"already addressed". Resolve with AUTOMERGE_TOKEN and fail the step
when a resolve fails, instead of warning.
Also skip threads whose last comment is an autofix reply: a declined
or unclear thread comes back only once a reviewer answers it.
|
Caution Review failedThe pull request is closed. Finishing Touches
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 |
Code reviewScope: one file, Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared: the whole PR against main (merge base 659873b to PR head a89de00).
|
- Skip a thread only when its last comment is the bot's own autofix reply, so a passer-by can't silence a thread by imitating one. - Post the summary whenever the push went through, even if a reply or resolve failed after it. - Resolve in a step of its own, so only those calls see the maintainer token. - Note why the threads to resolve go through a file.
| | select(.comments.nodes[-1] | ||
| | (.author.__typename == "Bot" and (.body | startswith("**Claude autofix ("))) | not) |
There was a problem hiding this comment.
Bug (medium confidence): the skip checks the thread's last comment from anyone, but the comment above says the thread "comes back once a reviewer replies". A passer-by's reply after an autofix reply therefore re-stages the thread. The staged comments array keeps only trusted authors, so Claude sees just its own earlier "fixed" reply and answers again ("already addressed"), which is the double answer this PR is meant to stop. Checking the last trusted comment fixes that. The jq is untested here: last on an empty array gives null, but comments.nodes[0] is already required to be trusted, so the array is never empty at this point.
| | select(.comments.nodes[-1] | |
| | (.author.__typename == "Bot" and (.body | startswith("**Claude autofix ("))) | not) | |
| | select(.comments.nodes | map(select(trusted)) | last | |
| | (.author.__typename == "Bot" and (.body | startswith("**Claude autofix ("))) | not) |
Related, low confidence: comments(first: 50) on line 149 has no pagination. In a thread with more than 50 comments, nodes[-1] is not the real last comment and the skip misses it. Fetching the comments with pagination, or reading totalCount, would close that gap.
| done | ||
|
|
||
| # Its own step so only these calls see the maintainer's token, which resolving takes: | ||
| # GITHUB_TOKEN can reply to a thread but not resolve it ("Resource not accessible by |
There was a problem hiding this comment.
Nit (medium confidence): the step split narrows which steps get the maintainer token in env, but it does not keep the token away from the rest of the job. The checkout uses token: AUTOMERGE_TOKEN with credentials persisted by default, so the token already sits in .git/config for every later step, including Reply and Summarise. The push step needs that persisted credential, so this is not a bug in the PR. The comment "so only these calls see the maintainer's token" is still stronger than the reality, and "only in this step's env" would be accurate.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared: the whole PR against main (merge base 659873b to PR head ec3ffb1).
|
Fixes two problems found by running the
claude-autofixworkflow on #972.Fixed threads weren't resolved. Every
resolveReviewThreadcall in the push job failed withgh: Resource not accessible by integration, in both runs 40438967670 and 40439326237.GITHUB_TOKENcan post a reply to a thread but can't resolve it, and the step only logged a warning. Resolving now usesAUTOMERGE_TOKEN, the maintainer token the job already pushes with. A failed resolve now fails the step instead of passing quietly.Threads were answered twice. Because the fixed threads stayed open, the second round staged them again. Claude correctly replied "declined: already addressed" under its own "fixed" reply. Fixing the resolve stops most of this. The thread staging now also skips any thread whose last comment is an autofix reply, so a declined or unclear thread only comes back once a reviewer answers it.
Tested: I ran the new filter against #972's threads. It stages 1 of the 8 open threads (the one nobody has answered yet), where the old filter staged all 8. actionlint and pre-commit pass.