Skip to content

fix(code-review): use --body-file to preserve newlines in summary comment#57199

Open
AoTo0330 wants to merge 1 commit intoanthropics:mainfrom
AoTo0330:fix-code-review-newlines
Open

fix(code-review): use --body-file to preserve newlines in summary comment#57199
AoTo0330 wants to merge 1 commit intoanthropics:mainfrom
AoTo0330:fix-code-review-newlines

Conversation

@AoTo0330
Copy link
Copy Markdown

@AoTo0330 AoTo0330 commented May 8, 2026

Summary

The code-review skill (plugins/code-review/commands/code-review.md) instructs the LLM to use gh pr comment for the no-issue summary comment, but does not specify a safe quoting form. When the LLM generates:

gh pr comment 449 -b "## Code review\n\n..."

bash does not interpret \n inside double quotes, so 2 literal characters (\ + n) are passed to gh and stored on GitHub as-is. The resulting comment renders as a single unreadable line in the GitHub UI.

This fix updates §7 of the skill prompt to mandate --body-file with a heredoc-written temp file, preserving real newlines through bash → gh → GitHub API.

Tracking issue

#57197 — includes reproduction (one occurrence in 8 PRs in a private downstream repo, ~12% rate; auto-recovered on next push).

Path coverage

This is the only LLM-driven path that handles raw bash strings:

Path Mechanism Affected?
Inline comments (mcp__github_inline_comment__create_inline_comment) Buffered to JSONL, posted via Octokit ✅ safe (JSON)
claude-code-action orchestration (run.ts etc.) Does not construct comment bodies ✅ safe
Skill's gh pr comment instruction (§7) LLM-generated bash ❌ vulnerable — fixed by this PR

Test plan

  • Trigger /code-review:code-review --comment <PR> against a PR with no issues
  • Verify the resulting comment renders newlines correctly in the GitHub UI (no literal \n)
  • Verify the raw body (via gh api repos/.../issues/<N>/comments) contains real LF characters, not \\n

…ment

When the LLM generates `gh pr comment <PR> -b "## Code review\n\n..."`, bash
does not interpret `\n` inside double quotes, so the body is stored on
GitHub as literal backslash-n characters. The resulting comment renders
as a single unreadable line.

Fix the skill prompt to mandate `--body-file` with a heredoc-written
temporary file, which preserves real newlines through bash → gh → GitHub
API.

Tracking upstream issue: anthropics#57197
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.

1 participant