{"record":{"id":"74115f8757081c0f","repo":"jaegertracing/jaeger","slug":"traceid-is-not-a-128bit-integer","errorCode":null,"errorMessage":"TraceID is not a 128bit integer","messagePattern":"TraceID is not a 128bit integer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/cassandra/spanstore/dbmodel/cql_udt.go","lineNumber":15,"sourceCode":"// Copyright (c) 2019 The Jaeger Authors.\n// Copyright (c) 2017 Uber Technologies, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\npackage dbmodel\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\n\tgocql \"github.com/apache/cassandra-gocql-driver/v2\"\n)\n\n// ErrTraceIDWrongLength is an error that occurs when cassandra has a TraceID that's not 128 bits long\nvar ErrTraceIDWrongLength = errors.New(\"TraceID is not a 128bit integer\")\n\n// MarshalCQL handles marshaling DBTraceID (e.g. in SpanRef)\nfunc (t TraceID) MarshalCQL(gocql.TypeInfo) ([]byte, error) {\n\treturn t[:], nil\n}\n\n// UnmarshalCQL handles unmarshaling DBTraceID (e.g. in SpanRef)\nfunc (t *TraceID) UnmarshalCQL(_ gocql.TypeInfo, data []byte) error {\n\tif len(data) != 16 {\n\t\treturn ErrTraceIDWrongLength\n\t}\n\tcopy(t[:], data)\n\treturn nil\n}\n\n// MarshalUDT handles marshalling a Tag.\nfunc (t *KeyValue) MarshalUDT(name string, info gocql.TypeInfo) ([]byte, error) {\n\tswitch name {","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/cassandra/spanstore/dbmodel/cql_udt.go#L1-L33","documentation":"ErrTraceIDWrongLength is returned by TraceID.UnmarshalCQL in dbmodel/cql_udt.go when the byte slice Cassandra holds for a trace_id is not exactly 16 bytes (128 bits). Jaeger trace IDs are fixed-size [16]byte values; anything else in the column means the data was written by an incompatible writer or corrupted. MarshalCQL always writes the full 16 bytes, so the error surfaces on read/unmarshal.","triggerScenarios":"UnmarshalCQL receives a byte slice whose length is not 16 while the gocql driver scans a trace_id column — e.g. rows written to the traces/spans table by an older schema or external tool storing shorter (32-bit/64-bit style) IDs, or malformed UDT data.","commonSituations":"Reading a Cassandra database populated by a different tracing backend or an outdated Jaeger schema; manual data migration copying truncated IDs; corrupt rows after partial migrations; tests like TestDBModelUDTMarshall that feed wrong-length bytes.","solutions":["Identify the offending rows (e.g. SELECT trace_id WHERE length mismatch) and fix or remove data that was not written as 16-byte IDs.","Ensure all writers use the same Jaeger schema version and 128-bit trace ID format before reading.","Re-migrate the data with a conversion step that pads/normalizes IDs to 16 bytes if legacy 8-byte IDs must be kept.","In application code, validate trace IDs at ingestion time so short IDs never reach storage."],"exampleFix":"// before\nid, _ := model.TraceIDFromString(\"abc123\") // may produce non-128-bit id stored elsewhere\n// after\nif len(idBytes) != 16 { /* normalize or reject before writing */ }","handlingStrategy":"validation","validationCode":"if len(traceIDBytes) != 16 {\n    return fmt.Errorf(\"trace ID must be 16 bytes, got %d\", len(traceIDBytes))\n}","typeGuard":"func isValidTraceID(b []byte) bool { return len(b) == 16 }","tryCatchPattern":"if err := row.Scan(&dbTraceID); err != nil {\n    if errors.Is(err, dbmodel.ErrTraceIDWrongLength) {\n        log.Warn(\"skipping row with corrupt trace_id\"); continue\n    }\n    return err\n}","preventionTips":["Validate trace ID length (16 bytes) at ingestion, before writing to Cassandra.","Never hand-edit or truncate trace_id columns; use the Jaeger schema and writer only.","Check for ErrTraceIDWrongLength with errors.Is when scanning legacy data."],"tags":["cassandra","trace-id","data-corruption","deserialization"],"backgroundTag":"invalid-trace-id-length","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}