{"record":{"id":"cb09ba268eb9dff2","repo":"jaegertracing/jaeger","slug":"invalid-trace-id-q-w","errorCode":null,"errorMessage":"invalid trace ID %q: %w","messagePattern":"invalid trace ID %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/integration/trace_reader.go","lineNumber":287,"sourceCode":"\t\t}\n\t}\n\treturn true\n}\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":269,"sourceCodeEnd":294,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/integration/trace_reader.go#L269-L294","documentation":"traceIDFromHex converts a 32-character hex string into a pcommon.TraceID. If hex.DecodeString fails (non-hex characters or odd-length string), the input is wrapped as 'invalid trace ID %q' with the decode error attached. This happens when converting trace IDs from api_v3 string fields back to binary form.","triggerScenarios":"GetTraceByName or similar paths parse a trace ID string that contains characters outside [0-9a-fA-F] or has an odd length, causing hex decoding to fail.","commonSituations":"Test fixtures or URLs containing malformed trace ID strings (e.g. 'abc', 'xyz123...', truncated or padded IDs); copying a trace ID that included non-hex separators; double-encoded or uppercase-containing values (those are fine) vs typos.","solutions":["Verify the trace ID string is exactly 32 hex characters (16 bytes) — e.g. with regexp ^[0-9a-f]{32}$ before decoding","Get the trace ID from a reliable source (the jaeger UI/API copy button) rather than retyping it","Strip any prefixes/separators (e.g. 'traceid=', whitespace, quotes) before parsing"],"exampleFix":"// before\nid := \"abcd-1234\" // malformed\ntraceID, err := traceIDFromHex(id)\n// after\nid := strings.TrimSpace(rawID)\nif matched, _ := regexp.MatchString(`^[0-9a-f]{32}$`, id); !matched {\n    return fmt.Errorf(\"not a 32-char hex trace ID: %q\", id)\n}\ntraceID, err := traceIDFromHex(id)","handlingStrategy":"validation","validationCode":"var traceIDHexRe = regexp.MustCompile(`^[0-9a-fA-F]{32}$`)\nfunc validTraceIDHex(s string) bool { return traceIDHexRe.MatchString(s) }","typeGuard":"func isTraceIDString(s string) bool {\n    return len(s) == 32 && regexp.MustCompile(`^[0-9a-fA-F]{32}$`).MatchString(s)\n}","tryCatchPattern":"tid, err := traceIDFromHex(raw)\nif err != nil {\n    var he *hex.InvalidByteError\n    if errors.As(err, &he) || errors.Is(err, hex.ErrLength) {\n        return fmt.Errorf(\"bad trace id %q\", raw)\n    }\n    return err\n}","preventionTips":["Validate trace IDs with a ^[0-9a-f]{32}$ regex at config/UI boundaries","Never retype trace IDs; copy them from the jaeger API/UI","Trim whitespace, quotes, and URL fragments before parsing"],"tags":["validation","hex-decode","trace-id"],"backgroundTag":"invalid-hex-trace-id","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}