GitHub Actions fromJSON "Unexpected end of JSON input"
fromJSON parses its argument as JSON. An empty output, a truncated multiline value, or an unset variable yields an empty string, which is not valid JSON and fails to parse.
What this error means
A matrix or value built with fromJSON fails at evaluation time, usually because the source step output was empty or got cut off.
Error: Unexpected end of JSON input while parsing ''Common causes
Source output is empty
The step that should produce JSON wrote nothing to GITHUB_OUTPUT, so fromJSON gets an empty string.
Multiline JSON output truncated
Writing multiline JSON to GITHUB_OUTPUT without a heredoc delimiter truncates it.
How to fix it
Emit valid, complete JSON
- Confirm the producing step prints non-empty JSON and writes it to GITHUB_OUTPUT.
- For multiline JSON, use a heredoc delimiter when writing to GITHUB_OUTPUT.
- Guard with a default like fromJSON(steps.gen.outputs.json || '[]').
- id: gen
run: |
{
echo 'json<<EOF'
cat matrix.json
echo 'EOF'
} >> "${GITHUB_OUTPUT}"How to prevent it
- Always validate that the JSON-producing step emits non-empty output.
- Use heredoc delimiters for any multiline GITHUB_OUTPUT value.