apache/cassandra · error · InvalidRequestException
Error decoding JSON value for %s: %s
Error message
Error decoding JSON value for %s: %s
What it means
Json.parseJson wraps per-column decode failures in this InvalidRequestException: the JSON value for a recognized column could not be converted to the column's type by spec.type.fromJSONObject. The MarshalException message (e.g. wrong type, out-of-range number, bad format) is appended after the column name.
Source
Thrown at src/java/org/apache/cassandra/cql3/Json.java:304
// explicit null value from no value
if (!valueMap.containsKey(spec.name.toString()))
continue;
Object parsedJsonObject = valueMap.remove(spec.name.toString());
if (parsedJsonObject == null)
{
// This is an explicit user null
columnMap.put(spec.name, Constants.NULL_VALUE);
}
else
{
try
{
columnMap.put(spec.name, spec.type.fromJSONObject(parsedJsonObject));
}
catch (MarshalException exc)
{
throw new InvalidRequestException(format("Error decoding JSON value for %s: %s", spec.name, exc.getMessage()));
}
}
}
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)
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Read the appended MarshalException message for the exact per-column reason
- Match JSON value types to schema: quoted strings for timestamps/uuids/durations, numbers within range for numeric columns
- Use toJson() on existing rows to see the exact JSON shape Cassandra accepts
- Validate payloads against the table schema (SystemSchema/describe) before insert
Example fix
// before
{"created": "2026-09-09T10:00:00Z"} // if timestamp format rejected
// after
{"created": "2026-09-09 10:00:00+0000"} // use Cassandra-accepted format Defensive patterns
Strategy: try-catch
Validate before calling
// validate one value against its column type before INSERT JSON spec.type.parse(rawJsonStringForValue); // throws InvalidRequest on mismatch
Try / catch
try { session.execute("INSERT INTO t JSON ?", json); } catch (InvalidRequestException e) { if (e.getMessage().startsWith("Error decoding JSON value for")) { String col = e.getMessage().split("for ")[1].split(":")[0].trim(); throw new IllegalArgumentException("Bad value for column " + col, e); } throw e; } Prevention
- Match JSON value types to column types (strings for timestamp/uuid/duration)
- Use toJson() output of existing rows as the canonical payload shape
- Check numeric ranges against column types before sending
- Generate payloads from the live schema, not hardcoded templates
When it happens
Trigger: INSERT INTO t JSON with a value that doesn't match the column type — a string where an int is expected, a malformed timestamp/uuid, a number too large for the column type, an invalid nested collection element.
Common situations: Sending ISO date strings where Cassandra expects its timestamp format; floats for decimal/int columns; JSON numbers exceeding column range; passing objects for non-collection columns; duration/tuple columns given string values in wrong internal format.
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
- Invalid timestamp value: <tval>
- Invalid TTL value: <tval>
- Got null for INSERT JSON values
- 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/22055d127d3109e6.
Report an issue: GitHub.