apache/cassandra · error · InvalidRequestException

JSON values map contains unrecognized column: %s

Error message

JSON values map contains unrecognized column: %s

What it means

Json.parseJson throws this InvalidRequestException when the JSON object contains keys that do not correspond to any expected column receiver. After mapping all known columns, any leftover keys indicate unknown columns, and the first unrecognized key name is reported.

Source

Thrown at src/java/org/apache/cassandra/cql3/Json.java:311

                    // 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)
        {
            throw new InvalidRequestException(exc.getMessage());
        }
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Compare JSON keys against the table's column names (DESCRIBE TABLE) and fix typos
  2. Remove or rename keys that no longer exist in the current schema
  3. Regenerate the JSON payload from the current schema instead of a hardcoded template
  4. Remember unquoted JSON keys are lowercased; quote keys exactly if the column has uppercase letters

Example fix

// before
{"user_id": 1, "emial": "x@y.com"}
// after
{"user_id": 1, "email": "x@y.com"}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> columns = keyspaceMetadata.getTable("t").getColumns().keySet();
for (String key : parsedJson.keySet())
    if (!columns.contains(key.toLowerCase()))
        throw new IllegalArgumentException("Unknown column in JSON: " + key);

Try / catch

try { session.execute("INSERT INTO t JSON ?", json); } catch (InvalidRequestException e) { if (e.getMessage().startsWith("JSON values map contains unrecognized column")) { reconcileSchema(e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: INSERT INTO t JSON with a key not in the table (typo, renamed/removed column, case-mismatched unquoted key, or targeting a table where the JSON was built for a different schema).

Common situations: Schema drift: application JSON written for an older table version; typos in column names; relying on case-insensitive keys after handleCaseSensitivity already rejected ambiguous case variants; inserting into a view/materialized-view base table with different columns.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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