Skip to content
Latchkey

GitHub Actions "The template is not valid" expression evaluation error

An expression parsed at load time but failed when evaluated at runtime, for example a fromJSON over invalid data or a format with a bad index.

What this error means

A job fails with "The template is not valid" and an evaluation error describing the failing expression.

github-actions
Error: The template is not valid. .github/workflows/ci.yml (Line: 22): Error while evaluating expression: fromJSON(steps.x.outputs.data)

Common causes

fromJSON over invalid JSON

If the upstream output is not valid JSON, fromJSON throws at evaluation time.

format placeholder out of range

A format string referencing {2} with only two arguments fails when evaluated.

How to fix it

Validate inputs before the expression evaluates

  1. Ensure outputs feeding fromJSON are valid JSON strings.
  2. Match every format placeholder to a supplied argument.
.github/workflows/ci.yml
- id: x
  run: echo 'data=["a","b"]' >> "$GITHUB_OUTPUT"
- run: echo ${{ join(fromJSON(steps.x.outputs.data), ',') }}

How to prevent it

  • Emit and validate JSON outputs before consuming them.
  • Keep expressions short and test them on a branch first.

Related guides

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