apache/cassandra · error · RuntimeException

Two ParamType-s that map to the same id: + type.id

Error message

Two ParamType-s that map to the same id: + type.id

What it means

The static initializer of ParamType builds an id-to-type lookup array and enforces that no two ParamType constants share the same wire id; duplicates would make deserialization ambiguous. It throws RuntimeException naming the colliding id.

Solutions

  1. Change the new ParamType's id to an unused non-negative value
  2. Audit all ParamType constants and list their ids to find the collision
  3. Restore correct ids after a conflicting merge in ParamType.java
  4. Add a CI test touching ParamType.values() so duplicate ids fail the build early

Example fix

// before
ParamType A(7, s1),
ParamType B(7, s2), // duplicate id 7
// after
ParamType A(7, s1),
ParamType B(8, s2),
Defensive patterns

Strategy: validation

Validate before calling

// CI-time duplicate check
Set<Integer> seen = new HashSet<>();
for (ParamType t : ParamType.values())
    if (!seen.add(t.id)) throw new IllegalStateException("duplicate ParamType id " + t.id);

Prevention

When it happens

Trigger: Static initialization of ParamType when two enum constants declare the same integer id — occurs when adding a new parameter type without checking existing ids, or after a bad merge.

Common situations: Contributors adding custom params in forks; backporting patches where ids were reassigned; copy-pasting a ParamType line and forgetting to bump the id.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/b80a9f256de5b9f2. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/net/ParamType.java:92

        this.serializer = serializer;
    }

    private static final ParamType[] idToTypeMap;

    static
    {
        ParamType[] types = values();

        int max = -1;
        for (ParamType t : types)
            max = max(t.id, max);

        ParamType[] idMap = new ParamType[max + 1];

        for (ParamType type : types)
        {
            if (idMap[type.id] != null)
                throw new RuntimeException("Two ParamType-s that map to the same id: " + type.id);
            idMap[type.id] = type;

        }

        idToTypeMap = idMap;
    }

    @Nullable
    static ParamType lookUpById(int id)
    {
        if (id < 0)
            throw new IllegalArgumentException("ParamType id must be non-negative (got " + id + ')');

        return id < idToTypeMap.length ? idToTypeMap[id] : null;
    }

}

View on GitHub (pinned to 88fd0f6a0e)