apache/cassandra · error · IllegalArgumentException
Value of type
Error message
Value of type
What it means
ClusterMetadataTransformer.with(key, value) type-checks the value against the ExtensionKey's declared valueType. If obj is not an instance of key.valueType, an IllegalArgumentException naming the actual and expected types is thrown.
Source
Thrown at src/java/org/apache/cassandra/tcm/ClusterMetadata.java:940
consensusMigrationState = new ConsensusMigrationState(Epoch.EMPTY, newTableMigrationStates);
}
return this;
}
public Transformer with(ConsensusMigrationState consensusMigrationState)
{
this.consensusMigrationState = consensusMigrationState;
return this;
}
public Transformer with(ExtensionKey<?, ?> key, ExtensionValue<?> obj)
{
if (MetadataKeys.CORE_METADATA.containsKey(key))
throw new IllegalArgumentException("Core cluster metadata objects should be addressed directly, " +
"not using the associated MetadataKey");
if (!key.valueType.isInstance(obj))
throw new IllegalArgumentException("Value of type " + obj.getClass() +
" is incompatible with type for key " + key +
" (" + key.valueType + ")");
extensions.put(key, obj);
modifiedKeys.add(key);
return this;
}
public Transformer withIfAbsent(ExtensionKey<?, ?> key, ExtensionValue<?> obj)
{
if (extensions.containsKey(key))
return this;
return with(key, obj);
}
public Transformer without(ExtensionKey<?, ?> key)
{
if (MetadataKeys.CORE_METADATA.containsKey(key))View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Pass a value whose runtime class matches (is an instance of) key.valueType.
- Use the correct ExtensionKey for the value type being stored.
- Add a local assert/instanceof check before calling with().
Example fix
// before transformer.with(MY_KEY, stringValue); // MY_KEY.valueType is Integer // after transformer.with(MY_KEY, 42); // or use the key matching stringValue's type
Defensive patterns
Strategy: type-guard
Validate before calling
if (!key.valueType.isInstance(value))
throw new IllegalArgumentException("Value " + value + " does not match key type " + key.valueType); Type guard
static <T> boolean matchesKeyType(ExtensionKey<T,?> key, Object value) {
return key.valueType.isInstance(value);
} Try / catch
try {
transformer.with(key, obj);
} catch (IllegalArgumentException e) {
logger.error("Extension value type mismatch: {}", e.getMessage());
} Prevention
- Keep ExtensionKey declarations and value classes together and versioned
- Prefer generics that tie the key to its value type at compile time
- Assert instanceof before calling with() in generic code paths
When it happens
Trigger: Calling with(ExtensionKey, ExtensionValue) where !key.valueType.isInstance(obj) — e.g. putting an object of the wrong class under an extension key, or mixing up keys between two extension types.
Common situations: Generic code passing Object/erased values, two extension keys with similar names swapped, or a value class changed without updating the ExtensionKey's valueType after a version upgrade.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Core cluster metadata objects should be addressed directly,
- Unknown endpoint %s
- Can only initialize cluster identifier during epoch %d, but
- Failed to find first CMS node in directory
- Cluster Metadata Identifier mismatch. Node is attempting to
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/177ea03a2a921eef.
Report an issue: GitHub.