{"record":{"id":"89654ede8aa222d0","repo":"apache/cassandra","slug":"expected-a-string-representation-of-a-uuid-but-go-89654e","errorCode":null,"errorMessage":"Expected a string representation of a uuid, but got a %s: %s","messagePattern":"Expected a string representation of a uuid, but got a (.+?): (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/UUIDType.java","lineNumber":245,"sourceCode":"            catch (IllegalArgumentException e)\n            {\n                throw new MarshalException(String.format(\"Unable to make UUID from '%s'\", source), e);\n            }\n        }\n\n        return null;\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        try\n        {\n            return new Constants.Value(fromString((String) parsed));\n        }\n        catch (ClassCastException exc)\n        {\n            throw new MarshalException(String.format(\n                    \"Expected a string representation of a uuid, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n        }\n    }\n\n    static int version(ByteBuffer uuid)\n    {\n        return (uuid.get(6) & 0xf0) >> 4;\n    }\n\n    @Override\n    public ByteBuffer getMaskedValue()\n    {\n        return MASKED_VALUE;\n    }\n}\n","sourceCodeStart":227,"sourceCodeEnd":261,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/UUIDType.java#L227-L261","documentation":"UUIDType.fromJSONObject only accepts JSON strings containing a UUID representation; any other JSON type (number, boolean, array, object) fails the (String) cast and produces this MarshalException reporting the actual type.","triggerScenarios":"Passing a parsed JSON number, boolean, list or map to UUIDType.fromJSONObject; e.g. fromJSONObject(42) or fromJSONObject(Map.of(...)).","commonSituations":"REST payloads delivering ids as integers; code generators mapping UUID columns to non-string JSON types; accidental passing of an already-parsed object instead of a string.","solutions":["Ensure the JSON value is a quoted string before parsing into a Term","Convert the object with String.valueOf or type-specific conversion first","Check the schema; if ids are numeric, use an integer type rather than uuid"],"exampleFix":"// before\nterm = uuidType.fromJSONObject(node.get(\"id\")); // id is numeric\n// after\nObject id = node.get(\"id\");\nif (!(id instanceof String)) id = String.valueOf(id);\nterm = uuidType.fromJSONObject(id);","handlingStrategy":"type-guard","validationCode":"if (!(parsed instanceof String)) throw new IllegalArgumentException(\"UUID must be a JSON string, got: \" + parsed);","typeGuard":"boolean isUuidString(Object o) { return o instanceof String && isUuid((String) o); }","tryCatchPattern":"try { term = uuidType.fromJSONObject(parsed); } catch (MarshalException e) { throw new JsonMappingException(\"uuid field must be string\"); }","preventionTips":["Serialize UUID fields as strings in JSON payloads","Map UUID columns to String in ORM/driver mappers","Validate JSON payloads against schema types before binding"],"tags":["cassandra","uuid","json","type-mismatch"],"backgroundTag":"type-mismatch","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"}