apache/cassandra · error · InvalidRequestException
(dynamic MarshalException message)
Error message
(dynamic MarshalException message)
What it means
Json.parseJson also catches MarshalException (raised inside JSON value handling outside the per-column decode wrapper) and rethrows it as an InvalidRequestException carrying the original dynamic message. The specific text depends on where the marshal failed — e.g. handleCaseSensitivity duplicate-key checks or nested term parsing — and is surfaced verbatim to the client.
Source
Thrown at src/java/org/apache/cassandra/cql3/Json.java:323
}
}
}
if (!valueMap.isEmpty())
{
throw new InvalidRequestException(format("JSON values map contains unrecognized column: %s",
valueMap.keySet().iterator().next()));
}
return columnMap;
}
catch (IOException exc)
{
throw new InvalidRequestException(format("Could not decode JSON string as a map: %s. (String was: %s)", exc.toString(), jsonString));
}
catch (MarshalException exc)
{
throw new InvalidRequestException(exc.getMessage());
}
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Read the dynamic message for the exact failing element
- Ensure JSON keys don't collide when lowercased; quote keys for case-sensitive identifiers
- Match nested JSON shapes to collection/UDT definitions (lists as arrays, maps as objects, tuples as arrays)
- Test the same payload via cqlsh to isolate driver-side formatting issues
Example fix
// before
{"Name": "a", "name": "b"} // case-colliding keys
// after
{"name": "b"} Defensive patterns
Strategy: try-catch
Validate before calling
// check key collisions after lowercasing (what handleCaseSensitivity enforces)
java.util.Set<String> seen = new java.util.HashSet<>();
for (String k : parsedJson.keySet())
if (!seen.add(k.toLowerCase())) throw new IllegalArgumentException("Duplicate key after lowercasing: " + k); Try / catch
try { session.execute("INSERT INTO t JSON ?", json); } catch (InvalidRequestException e) { log.error("JSON marshal failed: {} payload={}", e.getMessage(), json, e); throw e; } Prevention
- Avoid JSON keys differing only by case
- Match nested structures to collection/UDT definitions exactly
- Test nested payloads (maps, tuples, UDTs) against the schema
- Read the dynamic MarshalException message — it names the failing element
When it happens
Trigger: INSERT INTO t JSON where a MarshalException escapes the per-column catch: invalid nested collection/tuple/user-type JSON structure, or case-sensitivity violations in keys (handleCaseSensitivity throwing MarshalException).
Common situations: JSON keys that differ only by case for a case-insensitive schema (e.g. {"Name":..,"name":..}); malformed nested structures for frozen collections/UDTs that fail during Term preparation.
Understand the failure class
Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.
Related errors
- Unknown duration symbol '%s'
- Got null for INSERT JSON values
- Error decoding JSON value for %s: %s
- JSON values map contains unrecognized column: %s
- Could not decode JSON string as a map: %s. (String was: %s)
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/4d5c5af7fc9094b4.
Report an issue: GitHub.