{"record":{"id":"13f71d8e8424a7f1","repo":"apache/cassandra","slug":"expected-a-string-representation-of-a-uuid-but-go","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/LexicalUUIDType.java","lineNumber":134,"sourceCode":"        {\n            return decompose(UUID.fromString(source));\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new MarshalException(String.format(\"unable to make UUID from '%s'\", source), e);\n        }\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    @Override\n    public TypeSerializer<UUID> getSerializer()\n    {\n        return SERIALIZER;\n    }\n\n    @Override\n    public ArgumentDeserializer getArgumentDeserializer()\n    {\n        return ARGUMENT_DESERIALIZER;\n    }\n\n    @Override\n    public ByteBuffer getMaskedValue()","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/LexicalUUIDType.java#L116-L152","documentation":"LexicalUUIDType.fromJSONObject expects the parsed JSON value to be a String containing a UUID representation. If the JSON value is a number, object, array, or other non-string type, the cast (String) parsed fails and a MarshalException is thrown with this message.","triggerScenarios":"Using fromJSONObject (JSON INSERT / fromJson()) with a uuid column whose JSON value is a number, boolean, object, or array instead of a string.","commonSituations":"JSON documents where the UUID was serialized as a number or nested object by the producer; JavaScript clients serializing UUIDs without quotes; schema drift between producer and Cassandra table.","solutions":["Serialize the UUID as a quoted string in the JSON payload.","Convert the value to a string client-side before sending (e.g. String.valueOf or JSON.stringify of the id).","Fix the producer's serialization config so UUIDs map to JSON strings."],"exampleFix":"// before\n{\"id\": 12345}\n// after\n{\"id\": \"550e8400-e29b-41d4-a716-446655440000\"}","handlingStrategy":"type-guard","validationCode":"if (!(jsonValue instanceof String)) throw new IllegalArgumentException(\"uuid column expects a JSON string, got: \" + jsonValue.getClass().getSimpleName());","typeGuard":"boolean isJsonUuid(Object o) { return o instanceof String && UUID_RE.matcher((String) o).matches(); }","tryCatchPattern":"try { return lexicalType.fromJSONObject(parsed); } catch (MarshalException e) { throw new BadRequestException(\"uuid field must be a string: \" + e.getMessage()); }","preventionTips":["Serialize UUIDs as JSON strings in all producers.","Add a schema (e.g. JSON Schema) requiring type string for uuid fields.","Test payloads against the Cassandra column types before deployment."],"tags":["uuid","json","type-mismatch","marshal"],"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"}