{"record":{"id":"11b55152d982a3a4","repo":"apache/cassandra","slug":"json-values-map-contains-unrecognized-column-s","errorCode":null,"errorMessage":"JSON values map contains unrecognized column: %s","messagePattern":"JSON values map contains unrecognized column: (.+?)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/Json.java","lineNumber":311,"sourceCode":"                    // This is an explicit user null\n                    columnMap.put(spec.name, Constants.NULL_VALUE);\n                }\n                else\n                {\n                    try\n                    {\n                        columnMap.put(spec.name, spec.type.fromJSONObject(parsedJsonObject));\n                    }\n                    catch (MarshalException exc)\n                    {\n                        throw new InvalidRequestException(format(\"Error decoding JSON value for %s: %s\", spec.name, exc.getMessage()));\n                    }\n                }\n            }\n\n            if (!valueMap.isEmpty())\n            {\n                throw new InvalidRequestException(format(\"JSON values map contains unrecognized column: %s\",\n                                                         valueMap.keySet().iterator().next()));\n            }\n\n            return columnMap;\n        }\n        catch (IOException exc)\n        {\n            throw new InvalidRequestException(format(\"Could not decode JSON string as a map: %s. (String was: %s)\", exc.toString(), jsonString));\n        }\n        catch (MarshalException exc)\n        {\n            throw new InvalidRequestException(exc.getMessage());\n        }\n    }\n}\n","sourceCodeStart":293,"sourceCodeEnd":327,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/Json.java#L293-L327","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Compare JSON keys against the table's column names (DESCRIBE TABLE) and fix typos","Remove or rename keys that no longer exist in the current schema","Regenerate the JSON payload from the current schema instead of a hardcoded template","Remember unquoted JSON keys are lowercased; quote keys exactly if the column has uppercase letters"],"exampleFix":"// before\n{\"user_id\": 1, \"emial\": \"x@y.com\"}\n// after\n{\"user_id\": 1, \"email\": \"x@y.com\"}","handlingStrategy":"validation","validationCode":"Set<String> columns = keyspaceMetadata.getTable(\"t\").getColumns().keySet();\nfor (String key : parsedJson.keySet())\n    if (!columns.contains(key.toLowerCase()))\n        throw new IllegalArgumentException(\"Unknown column in JSON: \" + key);","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Regenerate JSON payloads when the schema changes","Compare keys against DESCRIBE TABLE output in CI","Avoid hardcoded JSON templates tied to old schemas","Quote keys exactly for case-sensitive column names"],"tags":["cql","json","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}