{"record":{"id":"cc78e53a0675e8d4","repo":"jaegertracing/jaeger","slug":"trace-id-must-be-16-bytes-got-d","errorCode":null,"errorMessage":"trace ID must be 16 bytes, got %d","messagePattern":"trace ID must be 16 bytes, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/integration/trace_reader.go","lineNumber":290,"sourceCode":"}\n\nfunc unwrapNotFoundErr(err error) error {\n\tif s, _ := status.FromError(err); s != nil {\n\t\tif strings.Contains(s.Message(), spanstore.ErrTraceNotFound.Error()) {\n\t\t\treturn spanstore.ErrTraceNotFound\n\t\t}\n\t}\n\treturn err\n}\n\n// traceIDFromHex parses a 32-character hex string into a pcommon.TraceID.\nfunc traceIDFromHex(s string) (pcommon.TraceID, error) {\n\tb, err := hex.DecodeString(s)\n\tif err != nil {\n\t\treturn pcommon.TraceID{}, fmt.Errorf(\"invalid trace ID %q: %w\", s, err)\n\t}\n\tif len(b) != 16 {\n\t\treturn pcommon.TraceID{}, fmt.Errorf(\"trace ID must be 16 bytes, got %d\", len(b))\n\t}\n\treturn pcommon.TraceID(b), nil\n}\n","sourceCodeStart":272,"sourceCodeEnd":294,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/integration/trace_reader.go#L272-L294","documentation":"After successful hex decoding, traceIDFromHex verifies the decoded byte slice is exactly 16 bytes, as required by pcommon.TraceID. A shorter or longer (but still valid hex) string is rejected with 'trace ID must be 16 bytes, got %d'. A 32-hex-char string decodes to exactly 16 bytes, so this fires for hex strings of any other even length.","triggerScenarios":"Parsing a hex string like 16 or 64 hex characters that decodes cleanly but is not 16 bytes — e.g. span IDs (8 bytes) passed where trace IDs are expected, or concatenated trace+span IDs.","commonSituations":"Passing a span ID instead of a trace ID; pasting a 64-hex-char 128-bit trace ID from another tracing system (W3C allows 16-byte, but 8-byte IDs from legacy systems are common); slicing errors in test data generators.","solutions":["Ensure the input is exactly 32 hex characters before calling; trim or validate length","If you have a span ID (16 hex chars), do not feed it as a trace ID — use the correct field","For variable-length sources, pad/left-align legacy 8-byte trace IDs to 16 bytes only if that is the intended semantic"],"exampleFix":"// before\ntraceID, err := traceIDFromHex(spanIDHex) // 16 hex chars = 8 bytes\n// after\nif len(traceIDHex) != 32 {\n    return fmt.Errorf(\"trace ID must be 32 hex chars, got %d\", len(traceIDHex))\n}\ntraceID, err := traceIDFromHex(traceIDHex)","handlingStrategy":"validation","validationCode":"func hasTraceIDLength(s string) bool { return len(s) == 32 } // 32 hex chars == 16 bytes","typeGuard":null,"tryCatchPattern":"tid, err := traceIDFromHex(s)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"trace ID must be 16 bytes\") {\n        return fmt.Errorf(\"%q is not a trace ID (span ID or foreign ID?)\", s)\n    }\n    return err\n}","preventionTips":["Distinguish trace IDs (32 hex chars) from span IDs (16 hex chars) in your data model","Validate length at ingestion/URL-routing time, before deep parsing","Pad legacy 8-byte trace IDs deliberately, only where semantics allow"],"tags":["validation","trace-id","length-check"],"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"}