Skip to content
Latchkey

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

  1. Generate JSON with a tool like jq -c so it is single-line and valid.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →