Repository navigation
ci: show why a Claude review failed, and run it on an API key with Claude Code directly - #53
Conversation
The review action hides Claude's output, so a failed review only logged "is_error: true" (it did on #52, with no tokens used). A new step after a failed review prints Claude's error and last result, which name the cause, such as an expired token.
The subscription token in CLAUDE_CODE_OAUTH_TOKEN was revoked. The review now uses ANTHROPIC_API_KEY whenever it's set, like Vivid's review, and falls back to the subscription token only when there's no key.
Reviews should come out of API credit, not a Claude subscription, so the workflow no longer reads CLAUDE_CODE_OAUTH_TOKEN at all. It needs the ANTHROPIC_API_KEY secret and skips the review without it.
An API key linked to an account rather than one workspace (sk-ant-usr-...) needs the workspace named on each request, or the API answers "Credit balance is too low" (it did on #53). The review now sends the ANTHROPIC_WORKSPACE_ID secret as the anthropic-workspace-id header, as Vivid's review does.
v1.0.248 bundles Claude Code 2.1.296, which answered every review with "Credit balance is too low" even though the same API key and workspace work for direct API calls and for Claude Code 2.1.327. v1.0.280 bundles 2.1.327. This also drops the temporary checks used to find that.
With an API key, every claude-code-action run (v1.0.248 and v1.0.280) was refused on its first request with "Credit balance is too low" (400), while the same key works for direct API calls and for the Claude Code CLI in the same job. The review now runs Claude Code 2.1.327 itself with the same prompt, model, turn limit and read-only tools, and posts inline comments with gh api. It no longer uses the workspace header, which the key doesn't need.
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| prompt: | | ||
| env: | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
There was a problem hiding this comment.
The description says the review sends ANTHROPIC_WORKSPACE_ID as an anthropic-workspace-id header via ANTHROPIC_CUSTOM_HEADERS, but neither appears in this diff. If the sk-ant-usr-... key still needs that header, the CLI will hit the same billing error. Add the env var here, or update the description to match what the PR does.
| run: | | ||
| LOG="$RUNNER_TEMP/claude-execution-output.json" | ||
| [ -s "$LOG" ] || { echo "::error::Claude left no output to read."; exit 0; } | ||
| jq -r '(if type == "array" then . else [.] end) |
There was a problem hiding this comment.
--output-format json writes one final result object, so there are no assistant messages and the Claude error: ... line will never print (the description says it did, which was the action's output file). Use --output-format stream-json --verbose or drop that branch and rely on the result text.
|
Two things to fix: the workspace header described in the PR isn't in the diff, and the failure step's |
Claude Code's --output-format json writes one result object, so the failure step now prints its result alone (found by the review on #53).
What this changes
The Claude review stopped working on 17 November, and the log only said
Claude result reported subtype success with is_error:true. This PR finds out why, and gets reviews running again on a Claude API key.CLAUDE_CODE_OAUTH_TOKENsubscription token had been revoked. The review now uses only theANTHROPIC_API_KEYsecret, billed to API credit like Vivid's review, and skips with a notice when it isn't set.claude-code-actionrun (v1.0.248 and v1.0.280) was refused on its first request with400 invalid_request_error: Credit balance is too low. The same key worked for direct API calls and for the Claude Code CLI in the same job, and the organisation has credit. So the review now installs Claude Code 2.1.327 and runs it directly, with the same prompt, model (claude-sonnet-5-5), 25-turn limit and read-only tools as before. Inline comments are posted withgh api(the CLI has no inline-comment tool), and Claude may only run that command for this PR. The summary comment and the "already reviewed" marker are unchanged.How I tested it
jqagainst a sample failed result./v1/messageswith the key returned 200 on Haiku and Sonnet, andclaude -pwith Claude Code 2.1.327 returned a normal answer, whileclaude-code-actionfailed with the error above.Release notes
AI disclosure (required)
AI tools used and what they did:
I designed and directed this change (surfacing Claude's own error when a review fails, moving the review to an API key, and running Claude Code directly once claude-code-action kept refusing a working key) and used Claude Opus to help write the workflow, track down the failures and write this description.
Checklist
fix: keep posters on Jellyfin 12.