{"record":{"id":"ae104273f0da2682","repo":"apache/cassandra","slug":"invalid-txnid","errorCode":null,"errorMessage":"Invalid TxnId: ","messagePattern":"Invalid TxnId: ","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/TxnIdUtf8Type.java","lineNumber":41,"sourceCode":"\nimport org.apache.cassandra.cql3.functions.ArgumentDeserializer;\nimport org.apache.cassandra.serializers.MarshalException;\nimport org.apache.cassandra.serializers.TypeSerializer;\nimport org.apache.cassandra.serializers.UTF8Serializer;\nimport org.apache.cassandra.utils.ByteBufferUtil;\n\npublic class TxnIdUtf8Type extends PseudoUtf8Type\n{\n    public static final TxnIdUtf8Type instance = new TxnIdUtf8Type();\n    static final TypeSerializer<String> txnIdSerializer = new UTF8Serializer()\n    {\n        @Override\n        public <V> void validate(V value, ValueAccessor<V> accessor) throws MarshalException\n        {\n            super.validate(value, accessor);\n            String str = deserialize(value, accessor);\n            if (!str.isEmpty() && null == TxnId.tryParse(str))\n                throw new MarshalException(\"Invalid TxnId: \" + str);\n        }\n    };\n\n    private static final ArgumentDeserializer ARGUMENT_DESERIALIZER = new DefaultArgumentDeserializer(instance);\n    private static final ByteBuffer MASKED_VALUE = ByteBufferUtil.EMPTY_BYTE_BUFFER;\n\n    TxnIdUtf8Type() {} // singleton\n\n    String describe() { return \"TxnId\"; }\n\n    @Override\n    public TypeSerializer<String> getSerializer()\n    {\n        return txnIdSerializer;\n    }\n\n    @Override\n    public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right, ValueAccessor<VR> accessorR)","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/TxnIdUtf8Type.java#L23-L59","documentation":"TxnIdUtf8Type's anonymous subtype validates that any non-empty string is parseable as an Accord TxnId via TxnId.tryParse. If the string is non-empty but cannot be parsed, validate throws MarshalException with the offending value appended to the message. This ensures only well-formed transaction identifiers are stored.","triggerScenarios":"Writing or comparing values against a txn-id-typed column where the string was not produced by TxnId.toString/toIdent — e.g. arbitrary text, truncated ids, or ids from an incompatible version.","commonSituations":"Application code inserting placeholder strings into Accord transaction-id columns; manual cqlsh inserts of copy-pasted/mangled ids; version mismatch where an older node writes ids a newer parser rejects (or vice versa).","solutions":["Only write TxnId values obtained from the Accord API (TxnId.toString/toIdent output)","Fix whatever generated the malformed id — verify it round-trips through TxnId.tryParse","Check cluster version consistency for Accord/transaction id format","If data is already corrupt, delete/rewrite the offending rows"],"exampleFix":"// before\nString id = someUserInput; // arbitrary text\nsession.execute(\"INSERT INTO txns (id, ...) VALUES (?, ...)\", id, ...);\n// after\nif (TxnId.tryParse(id) == null) throw new IllegalArgumentException(\"not a TxnId: \" + id);\nsession.execute(\"INSERT INTO txns (id, ...) VALUES (?, ...)\", id, ...);","handlingStrategy":"validation","validationCode":"if (!str.isEmpty() && TxnId.tryParse(str) == null)\n    throw new IllegalArgumentException(\"not a valid TxnId: \" + str);","typeGuard":null,"tryCatchPattern":"try {\n    txnIdType.validate(value, accessor);\n} catch (MarshalException e) {\n    log.error(\"Rejecting malformed TxnId: {}\", e.getMessage());\n}","preventionTips":["Only store ids produced by TxnId.toString/toIdent","Round-trip-check ids with TxnId.tryParse before persisting","Keep Accord-related formats consistent across cluster versions"],"tags":["accord","validation","txn-id"],"backgroundTag":"invalid-identifier-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}