{"record":{"id":"9dce6a4798c2515b","repo":"apache/cassandra","slug":"unknown-timeuuid-representation-s","errorCode":null,"errorMessage":"Unknown timeuuid representation: %s","messagePattern":"Unknown timeuuid representation: (.+?)","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/AbstractTimeUUIDType.java","lineNumber":161,"sourceCode":"               |  (input >>> 32);\n    }\n\n    protected static long reorderBackTimestampBytes(long input)\n    {\n        // In a time-based UUID the high bits are significantly more shuffled than in other UUIDs - if [X] represents a\n        // 16-bit tuple, [1][2][3][4] should become [3][4][2][1].\n        // See the UUID Javadoc (and more specifically the high bits layout of a Leach-Salz UUID) to understand the\n        // reasoning behind this bit twiddling in the first place (in the context of comparisons).\n        return (input << 32)\n               | ((input >>> 16) & 0xFFFF0000L)\n               | (input >>> 48);\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n        ByteBuffer parsed = UUIDType.parse(source);\n        if (parsed == null)\n            throw new MarshalException(String.format(\"Unknown timeuuid representation: %s\", source));\n        if (parsed.remaining() == 16 && UUIDType.version(parsed) != 1)\n            throw new MarshalException(\"TimeUUID supports only version 1 UUIDs\");\n        return parsed;\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(\n                    String.format(\"Expected a string representation of a timeuuid, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n        }\n    }","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/AbstractTimeUUIDType.java#L143-L179","documentation":"fromString delegates to UUIDType.parse, which accepts a UUID string or (in some versions) date-based literal; when the string cannot be parsed as any known timeuuid representation, this MarshalException is thrown.","triggerScenarios":"Calling AbstractTimeUUIDType.fromString with a string that is not a valid UUID literal nor a recognized timeuuid literal (e.g. 'now()', a bare date string unsupported by this version, or a typo'd UUID).","commonSituations":"INSERT/UPDATE CQL with an invalid literal like '550e8400-e29b-41d4-a716-446655440000x'; using date strings for timeuuid on a Cassandra version that doesn't support them; application passing user input unvalidated.","solutions":["Supply a canonical version-1 UUID string (8-4-4-4-12 hex with version nibble 1).","Use now() in CQL to let the server generate a timeuuid.","Validate/parse with UUID.fromString() client-side before sending, and check version()==1."],"exampleFix":"// before\nstmt.setString(\"id\", \"2024-01-01 00:00:00\");\n// after\nstmt.setString(\"id\", UUIDGen.getTimeUUID().toString());","handlingStrategy":"try-catch","validationCode":"boolean ok;\ntry { java.util.UUID.fromString(s); ok = true; } catch (IllegalArgumentException e) { ok = false; }","typeGuard":"boolean isTimeUUIDLiteral(String s) { try { return java.util.UUID.fromString(s).version() == 1; } catch (Exception e) { return false; } }","tryCatchPattern":"catch (MarshalException e) { throw new IllegalArgumentException(\"Invalid timeuuid literal: \" + source, e); }","preventionTips":["Validate/parse timeuuid strings client-side before sending to Cassandra.","Prefer now() in CQL for server-generated timeuuids.","Check your Cassandra version's supported literal formats (date-based literals need newer versions)."],"tags":["uuid","parsing","invalid-format"],"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"}