Skip to content
Latchkey

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.

Actions
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

  1. Print the upstream output and confirm it is a JSON array or object.
  2. Ensure the producing step wrote it to $GITHUB_OUTPUT as one line.
  3. Reference it via needs.<job>.outputs.<name> inside fromJSON().
.github/workflows/ci.yml
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.

Frequently asked questions

What causes ""Error when evaluating 'strategy'""?
The value passed to fromJSON() was empty, truncated, or not valid JSON, so parsing failed while the matrix was being computed.
How do I fix "Error when evaluating 'strategy'"?
Feed fromJSON a valid JSON string

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card