GitHub Actions matrix include creates an unexpected combination
matrix include follows specific rules: if an include entry can be merged into an existing combination without overwriting a vector value, it augments it; otherwise it adds a new combination. Misunderstanding this produces surprise jobs.
What this error means
The matrix expands to more (or different) jobs than expected after adding include entries, with values applied to combinations you did not intend.
github-actions
# Expected 2 jobs, got 3 because this include adds a new combination:
strategy:
matrix:
node: [18, 20]
include:
- node: 22
experimental: trueCommon causes
include adds a new combination
An include with a vector value not already present creates an extra job.
include augments unexpectedly
An include that merges into existing combinations adds fields you did not anticipate.
How to fix it
Apply include rules deliberately
- Use include only to add fields to existing combinations or to add explicit new ones.
- List base vectors explicitly and verify the expanded job list.
- Use exclude to remove unwanted combinations rather than fighting include.
.github/workflows/ci.yml
strategy:
matrix:
node: [18, 20]
include:
- node: 20
coverage: true # augments only the node:20 jobHow to prevent it
- Review the expanded matrix in the Actions UI after editing include.
- Prefer exclude for trimming and explicit include entries for additions.
Related guides
GitHub Actions "Unrecognized named-value: 'matrix'"Fix "Unrecognized named-value: 'matrix'" in GitHub Actions - the matrix context was referenced where it is no…
GitHub Actions matrix value not interpolating in job nameFix a GitHub Actions job name showing the literal expression instead of the matrix value - the name field nee…
GitHub Actions fromJSON "Unexpected end of JSON input"Fix GitHub Actions fromJSON "Unexpected end of JSON input" - fromJSON received an empty or truncated string.