GitHub Actions "Error when evaluating 'strategy' for job" in CI
GitHub evaluated the expressions in strategy to build the matrix and one of them threw. The most common trigger is a fromJSON() over a value that is not valid JSON, or a context reference that does not resolve at strategy-evaluation time.
What this error means
The job fails before any step runs with "Error when evaluating 'strategy' for job '<id>'." followed by a hint about the expression or the offending input.
Error when evaluating 'strategy' for job 'test'.
.github/workflows/ci.yml (Line: 20, Col: 15): Unexpected symbol: '"'.
Located at position 1 within expression: fromJSON(needs.setup.outputs.matrix)Common causes
fromJSON received invalid or non-string input
The value passed to fromJSON() was empty, truncated, or not valid JSON, so parsing failed while the matrix was being computed.
A context used in strategy is not yet available
Only a limited set of contexts (github, needs, vars, inputs) is available when strategy is evaluated. Referencing matrix, env, or steps there fails.
How to fix it
Feed fromJSON a valid JSON string
- Print the upstream output and confirm it is a JSON array or object.
- Ensure the producing step wrote it to
$GITHUB_OUTPUTas one line. - Reference it via
needs.<job>.outputs.<name>insidefromJSON().
strategy:
matrix:
include: ${{ fromJSON(needs.setup.outputs.matrix) }}Only reference contexts available in strategy
Move any dependence on env or steps out of strategy; use github, needs, vars, or inputs to compute the matrix.
How to prevent it
- Validate that any fromJSON input is well-formed JSON before the matrix job.
- Restrict strategy expressions to contexts that exist at evaluation time.
- Echo the raw output in the producing job for quick debugging.