ci: fix AI review workflow crash and make it advisory - #60
Conversation
The `review` check has been failing on every PR, red-flagging and blocking
merges on healthy code. Root cause chain:
1. `--max-turns 15` was too low for the prompt's workload (read the diff, leave
inline comments, post a summary comment, AND return a structured verdict).
The run ended as error_max_turns with an empty structured_output.
2. That empty value hit an UNGUARDED expression in the approve step's `env:`
block: `fromJSON(steps.review.outputs.structured_output).summary`. GitHub
evaluates `env:` even when the step's `if:` is false, so the guard on the
`if:` did not protect it. fromJSON('') is a workflow *template* parse error
("Error reading JToken from JsonReader"), which fails the entire run rather
than skipping the step.
Fixes:
- Guard the SUMMARY env expression independently of the `if:`, with a comment
explaining why both guards are required.
- Raise --max-turns 15 -> 40 so the verdict is actually emitted.
- Mark the review step continue-on-error: an infra failure (turn exhaustion,
rate limit, action outage) should not gate a healthy PR. The approve step
still runs only on an explicit has_blockers == false verdict, so this
degrades to "no automated approval", never to "silently approved".
- Add a step that records a missing verdict in the job summary, so a soft
failure is visible rather than silently green.
Security boundary unchanged: still `pull_request`, never pull_request_target.
Model ID claude-opus-4-8 left as-is (verified current and valid).
Verified: YAML parses; confirmed the trigger and token handling are untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
CI evidence on this PRThe This is the exact scenario that previously killed the workflow. One caveat, stated plainly: the review step reported Worth noting the no-op path is itself now safe: previously an empty verdict was fatal, so this failure mode would have red-flagged the PR regardless of cause. |
Problem
The
reviewcheck is failing on every PR in this repo, red-flagging healthy code and putting PRs intoBLOCKEDmerge state. It is a workflow defect, not a code defect.Root cause
--max-turns 15was too low for the prompt's workload (read diff → inline comments → summary comment → structured verdict). Runs ended aserror_max_turnswith an emptystructured_output.env:block:env:even when the step'sif:is false, so the existingif:guard did not protect it.fromJSON('')is a workflow template parse error —Error reading JToken from JsonReader— which fails the whole run instead of skipping the step.Observed in job logs:
subtype: error_max_turns→--json-schema was provided but Claude did not return structured_output→The template is not valid ... (Line: 120, Col: 20).Fix
SUMMARYexpression independently of theif:, with a comment explaining why both guards are needed.--max-turns15 → 40 so the verdict is actually emitted.continue-on-error: trueon the review step — infra failures shouldn't gate a healthy PR.Safety
has_blockers == falseverdict. Failing soft degrades to no automated approval, never to approved.pull_request, neverpull_request_target.claude-opus-4-8verified current and valid; left untouched.Verification
YAML parses; trigger, permissions, and token handling confirmed unchanged.
🤖 Generated with Claude Code