Skip to content
Latchkey

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.

Actions
strategy:
  matrix:
    node: [18, 20]
    include:
      - node: 20   # 20 already exists in the base vector, creating a duplicate

Common 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

  1. Drop include entries that only restate a base combination.
  2. If the include is meant to add a field, keep the field so the leg differs.
  3. Verify the expanded matrix has no identical legs.
.github/workflows/ci.yml
strategy:
  matrix:
    node: [18, 20]
    include:
      - node: 20
        coverage: true   # now distinct, not a duplicate

De-duplicate a dynamic matrix

Use jq to remove repeated entries before emitting the matrix JSON.

bash
jq -c 'unique' entries.json

How 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →