{"record":{"id":"20bb7c2111a63459","repo":"apache/cassandra","slug":"cannot-parse-map-value-from-s-at-character-d-20bb7c","errorCode":null,"errorMessage":"Cannot parse map value from \"%s\", at character %d expecting ',' but got '%c'","messagePattern":"Cannot parse map value from \"(.+?)\", at character (.+?) expecting ',' but got '%c'","errorType":"exception","errorClass":"InvalidTypeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java","lineNumber":2416,"sourceCode":"                }\n                catch (IllegalArgumentException e)\n                {\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse map value from \\\"%s\\\", invalid CQL value at character %d\",\n                    value, idx),\n                    e);\n                }\n\n                V v = valueCodec.parse(value.substring(idx, n));\n                idx = n;\n\n                m.put(k, v);\n\n                idx = ParseUtils.skipSpaces(value, idx);\n                if (value.charAt(idx) == '}') return m;\n                if (value.charAt(idx++) != ',')\n                    throw new InvalidTypeException(\n                    String.format(\n                    \"Cannot parse map value from \\\"%s\\\", at character %d expecting ',' but got '%c'\",\n                    value, idx, value.charAt(idx)));\n\n                idx = ParseUtils.skipSpaces(value, idx);\n            }\n            throw new InvalidTypeException(\n            String.format(\"Malformed map value \\\"%s\\\", missing closing '}'\", value));\n        }\n\n        @Override\n        public String format(Map<K, V> value)\n        {\n            if (value == null) return \"NULL\";\n            StringBuilder sb = new StringBuilder();\n            sb.append('{');\n            int i = 0;\n            for (Map.Entry<K, V> e : value.entrySet())","sourceCodeStart":2398,"sourceCodeEnd":2434,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/functions/types/TypeCodec.java#L2398-L2434","documentation":"Thrown while parsing a map literal when, after finishing an entry, the next non-space character is neither '}' (end of map) nor ',' (entry separator). The parser reports the offending character, indicating entries are separated by an invalid token.","triggerScenarios":"Calling MapCodec.parse() with wrong entry separators such as \"{1:'a';2:'b'}\" (semicolon), \"{1:'a' 2:'b'}\" (missing separator), or a newline where a comma is expected.","commonSituations":"Literals copied from JSON or another language using ';'/newline separators; template-generated strings with the wrong join character; whitespace formatting that dropped the comma.","solutions":["Separate map entries with ',' only","Verify the overall shape {k1:v1,k2:v2} before parsing","Generate the literal with codec.format() instead of manual concatenation"],"exampleFix":"// before\nmapCodec.parse(\"{1:'a';2:'b'}\");\n// after\nmapCodec.parse(\"{1:'a',2:'b'}\");","handlingStrategy":"validation","validationCode":"if (value.contains(\";\"))\n    throw new IllegalArgumentException(\"Separate map entries with ',': \" + value);\nmapCodec.parse(value);","typeGuard":null,"tryCatchPattern":"try {\n    mapCodec.parse(value);\n} catch (InvalidTypeException e) {\n    throw new IllegalArgumentException(\"Entries must be comma-separated: \" + value, e);\n}","preventionTips":["Join entries with ',' only — no semicolons or bare newlines","When templating literals, double-check the join delimiter","Use codec.format() to build literals"],"tags":["cql","parsing","map","codec"],"backgroundTag":"invalid-argument-format","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"}