fix(ci): backend reviewer upserts a sticky comment and unblocks fixed PRs - #36485
Conversation
…ppending
The Claude Backend Code Reviewer posted a brand-new comment on every push and
never updated the previous one, so once a push resolved the reported findings
the stale comment kept showing already-fixed 🟠/🔴 issues, and the clean
"no issues found" state was posted unreliably.
STEP 5 now upserts a single comment identified by the hidden
`<!-- dotcms-backend-review -->` marker: it edits the existing comment in place
(PATCH /issues/comments/{id}) and only creates one on the first run. The upsert
always runs, including when the result is "no issues found", so the comment
always reflects the current state of the branch. No allowlist change needed —
listing and PATCHing issue comments were already permitted.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… unblock STEP 6 already approves when no Critical/High findings remain (which supersedes a prior request-changes and unblocks the PR), but `gh pr review` was never in the orchestrator's allowedTools, so the step could not run — the reviewer left PRs blocked even after the findings were fixed. Add `Bash(gh pr review*)` to allowedTools and clarify STEP 6 that the reviewer's latest review supersedes its previous one, so a later approve clears an earlier request-changes automatically. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
❌ Issue Linking RequiredThis PR could not be linked to an issue. All PRs must be linked to an issue for tracking purposes. How to fix this:Option 1: Add keyword to PR body (Recommended - auto-removes this comment)
Why is this required?Issue linking ensures proper tracking, documentation, and helps maintain project history. It connects your code changes to the problem they solve.--- This comment was automatically generated by the issue linking workflow |
|
Claude finished @dsilvam's task in 1m 36s —— View job Code Review
I reviewed the full diff against New Issues
Notes (non-blocking, verified correct)
|
|
Tick the box to add this pull request to the merge queue (same as
|
The comment lookup used an aggregate jq filter (`[...] | last | .id`) with `gh --paginate`. gh runs `--jq` once per page and concatenates, so the aggregate returned a per-page result and pages with no match emitted `null` — producing a multi-line EXISTING_ID (e.g. "12345\nnull") on PRs with more than one page of comments. That passed the `-n`/`!= "null"` guards, took the PATCH branch with a malformed URL, and silently stopped updating the sticky comment — the exact staleness this change is meant to prevent, just gated behind a comment count. Emit one bare id per matching comment and take the global last with `tail -n1` (non-matching pages emit nothing, not `null`); drop the now-redundant `!= "null"` guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Proposed Changes
Fixes two problems with the Claude Backend Code Reviewer workflow (
.github/workflows/ai_claude-backend-reviewer.yml) where the reviewer failed to reflect that reported issues had been fixed:Sticky comment (STEP 5). The reviewer posted a brand-new comment on every push and never updated the previous one, so once a push resolved the findings the stale comment kept showing already-fixed 🟠/🔴 issues, and the clean "no issues found" state was posted unreliably. It now upserts a single comment identified by the hidden
<!-- dotcms-backend-review -->marker — editing it in place (PATCH /issues/comments/{id}) and creating one only on the first run. The upsert always runs, including when the result is "no issues found", so the comment always reflects the current state of the branch. No allowlist change was needed for this (listing + PATCHing issue comments were already permitted).Formal review could never run (STEP 6). STEP 6 already approves when no Critical/High findings remain — which supersedes a prior
--request-changesand unblocks the PR — butgh pr reviewwas never in the orchestrator'sallowedTools, so the step was silently blocked and PRs stayed blocked even after fixes. AddedBash(gh pr review*)toallowedToolsand clarified STEP 6 that the reviewer's latest review supersedes its previous one.Root cause
The prompt instructed "post it as a new comment (each push gets its own comment for a historical record)" with the clean-path as a weak secondary clause, and
gh pr reviewwas omitted from the sandbox allowlist.Checklist
Additional Info
Security note: no expansion of the sandbox beyond formal PR reviews. The comment upsert reuses the already-permitted
gh api .../issues/comments/*scope; the only new capability isgh pr review, needed for the merge-gating that STEP 6 already intends to perform.Caveat to verify: the STEP 6
--approvepath also depends on the org/repo setting "Allow GitHub Actions to create and approve pull requests." If that setting is off, the bot's approve may still be rejected by GitHub regardless of the allowlist; the--request-changespath is unaffected. Worth confirming during rollout.🤖 Generated with Claude Code