GitHub Actions matrix produced duplicate combinations in CI
A matrix can end up with duplicate legs when an include entry re-specifies a combination that the base vectors already generate, or when a dynamic matrix emits repeated entries. Duplicates waste runner minutes and can collide on outputs.
What this error means
The expanded matrix shows two legs with identical values, so the same combination runs twice and may fight over shared artifact or cache keys.
strategy:
matrix:
node: [18, 20]
include:
- node: 20 # 20 already exists in the base vector, creating a duplicateCommon causes
An include re-adds an existing combination
When an include entry sets only vector keys that already form a base combination, and adds no new field that distinguishes it, the leg is effectively duplicated.
A dynamic matrix emitted repeated entries
Generation from data without de-duplication can emit the same object more than once, producing identical legs.
How to fix it
Remove the redundant include or add a distinguishing field
- Drop include entries that only restate a base combination.
- If the include is meant to add a field, keep the field so the leg differs.
- Verify the expanded matrix has no identical legs.
strategy:
matrix:
node: [18, 20]
include:
- node: 20
coverage: true # now distinct, not a duplicateDe-duplicate a dynamic matrix
Use jq to remove repeated entries before emitting the matrix JSON.
jq -c 'unique' entries.jsonHow to prevent it
- Do not include a combination the base vectors already produce.
- De-duplicate dynamic matrix data with jq unique.
- Inspect the expanded matrix to catch repeated legs.