GitHub Actions fromJSON parse error
fromJSON received a string that is not valid JSON, so it throws at evaluation. The job fails before the step runs.
What this error means
A job fails with an error while evaluating fromJSON, often because the upstream output was empty or not JSON.
github-actions
Error: Unexpected token in JSON. Error while evaluating expression: fromJSON(needs.setup.outputs.matrix)Common causes
Empty or unset output
If the producing step did not write the output, fromJSON gets an empty string.
Improperly escaped JSON
Newlines or unescaped quotes in the emitted string break JSON parsing.
How to fix it
Emit compact, valid JSON
- Generate JSON with a tool like jq -c so it is single-line and valid.
- Confirm the output key matches the reference exactly.
.github/workflows/ci.yml
- id: setup
run: echo "matrix=$(jq -cn '["a","b"]')" >> "$GITHUB_OUTPUT"How to prevent it
- Always produce matrix JSON with jq -c, never hand-built strings.
- Log the JSON before consuming it with fromJSON.
Related guides
GitHub Actions "The template is not valid" expression evaluation errorFix the GitHub Actions "The template is not valid" runtime expression evaluation error caused by a function o…
GitHub Actions "Matrix vector has no values to expand"Fix the GitHub Actions error where a matrix dimension expands to no values, producing a skipped job or a vali…
GitHub Actions "Unrecognized function" in an expressionFix the GitHub Actions expression error "Unrecognized function" caused by calling a function that does not ex…