{"record":{"id":"bb9625cf95a924a4","repo":"apache/cassandra","slug":"value-s-is-not-a-valid-representation-of-a-deci","errorCode":null,"errorMessage":"Value '%s' is not a valid representation of a decimal value","messagePattern":"Value '(.+?)' is not a valid representation of a decimal value","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/DecimalType.java","lineNumber":309,"sourceCode":"        }\n        catch (Exception e)\n        {\n            throw new MarshalException(String.format(\"unable to make BigDecimal from '%s'\", source), e);\n        }\n\n        return decompose(decimal);\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        try\n        {\n            return new Constants.Value(fromString(Objects.toString(parsed)));\n        }\n        catch (NumberFormatException | MarshalException exc)\n        {\n            throw new MarshalException(String.format(\"Value '%s' is not a valid representation of a decimal value\", parsed));\n        }\n    }\n\n    @Override\n    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)\n    {\n        return Objects.toString(getSerializer().deserialize(buffer), \"\\\"\\\"\");\n    }\n\n    public CQL3Type asCQL3Type()\n    {\n        return CQL3Type.Native.DECIMAL;\n    }\n\n    public TypeSerializer<BigDecimal> getSerializer()\n    {\n        return DecimalSerializer.instance;\n    }","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/DecimalType.java#L291-L327","documentation":"DecimalType.fromJSONObject converts the JSON value to a string and calls fromString; NumberFormatException or MarshalException from that parse is rethrown as this MarshalException naming the offending JSON value. It exists to give JSON-import flows a clear, value-specific message.","triggerScenarios":"fromJSONObject invoked with a JSON value whose string form is not a valid decimal (e.g. true, null-converted string, '12.3.4').","commonSituations":"COPY FROM JSON, cqlsh JSON input, or driver JSON serialization emitting booleans/nulls/strings into decimal columns.","solutions":["Fix the JSON document so the decimal field is a number or a valid decimal string","Coerce/validate the field before calling fromJSONObject","Map bad rows to a dead-letter log instead of failing the whole import"],"exampleFix":"// before\n{\"amount\": \"12.3.4\"}\n// after\n{\"amount\": \"12.34\"}","handlingStrategy":"try-catch","validationCode":"Object v = json.get(\"amount\"); boolean ok = v instanceof Number || (v instanceof String && isDecimalLiteral((String) v));","typeGuard":"boolean isValidDecimalJson(Object v) { return v instanceof Number || (v instanceof String && v.toString().matches(\"[+-]?\\\\d+(\\\\.\\\\d+)?\")); }","tryCatchPattern":"try { DecimalType.instance.fromJSONObject(parsed); } catch (MarshalException e) { /* log parsed value, route row to error queue */ }","preventionTips":["Pre-validate JSON decimal fields (number or numeric string)","Reject booleans/nulls at the JSON schema level","Handle per-row failures instead of aborting the whole import"],"tags":["json","decimal","marshal"],"backgroundTag":"invalid-number-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"}