Skip to content

claude-code-review still republishes a raw gh pr comment invocation as the review body (--edit-last variant, gha#312 regression) #381

Description

@dem-extra1

Summary

The exact failure mode #312 described — claude-code-review.yml's "Post review comment" step republishing the reviewer's own raw shell command instead of the review text — recurred on PR #380, in a form the unwrap_posted_body fix from #318 doesn't catch.

Evidence

Seen on Morrison-Lab/gha#380, run 30530903965.

The reviewer initially posted a placeholder comment (test-can-i-post, then edited to placeholder - real review incoming), then used a Bash tool call to edit that same comment into its real review via:

gh pr comment 380 --repo Morrison-Lab/gha --edit-last --body '## Code review
...
**Verdict: Ready for merge** ...'

That edit worked correctly — the claude[bot] comment ended up showing the rendered review text, verdict included.

But separately, the workflow's own "Post review comment" step (which extracts review_text_file from the execution output and reposts it via gh pr comment as github-actions[bot]) posted the literal command above, verbatim, as a new comment — not the review text it wrapped. So the PR again ended up with the review twice: once rendered correctly (claude[bot]), once as an unrendered shell command (github-actions[bot]) — the same duplicate-and-garbled pattern #312 reported.

Why #318's fix doesn't catch this

#318's unwrap_posted_body in check-review-execution.sh specifically matches the heredoc form:

gh pr comment N --body "$(cat <<'EOF'
...
EOF
)"

This occurrence uses a different shape entirely — --edit-last --body '...' with a single-quoted literal string, no heredoc at all. The regex that extracts heredoc contents has nothing to unwrap here, so the whole command (including --edit-last) passes through as the "review text" unchanged.

Suggested fix

Generalize unwrap_posted_body (or add a sibling case) to also recognize a plain gh (pr|issue) comment ... --body '...' / --body "..." invocation (with or without --edit-last) and extract the quoted argument, not just the heredoc form. Both shapes are "the reviewer posted its own comment via Bash instead of returning prose," so the fix should probably key on "this Bash tool_use block's command matches gh (pr|issue) comment" generally and try several known argument shapes, rather than only the heredoc one.

Worth adding a regression fixture with this --edit-last --body '...' shape alongside the existing heredoc fixture, so both variants are pinned.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions