{"record":{"id":"d3d348197634a5c9","repo":"jaegertracing/jaeger","slug":"invalid-trace-id-w","errorCode":null,"errorMessage":"invalid trace_id: %w","messagePattern":"invalid trace_id: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go","lineNumber":99,"sourceCode":"\t\treturn nil, types.GetCriticalPathOutput{}, fmt.Errorf(\"failed to compute critical path: %w\", err)\n\t}\n\n\t// Build output\n\toutput := h.buildOutput(input.TraceID, trace, criticalPathSections)\n\n\treturn nil, output, nil\n}\n\n// buildQuery converts GetCriticalPathInput to querysvc.GetTraceParams.\nfunc (*getCriticalPathHandler) buildQuery(input types.GetCriticalPathInput) (querysvc.GetTraceParams, error) {\n\t// Validate input\n\tif input.TraceID == \"\" {\n\t\treturn querysvc.GetTraceParams{}, errors.New(\"trace_id is required\")\n\t}\n\n\ttraceID, err := parseTraceID(input.TraceID)\n\tif err != nil {\n\t\treturn querysvc.GetTraceParams{}, fmt.Errorf(\"invalid trace_id: %w\", err)\n\t}\n\n\treturn querysvc.GetTraceParams{\n\t\tTraceIDs: []tracestore.GetTraceParams{\n\t\t\t{TraceID: traceID},\n\t\t},\n\t\tRawTraces: false, // We want adjusted traces\n\t}, nil\n}\n\n// buildOutput constructs the GetCriticalPathOutput from the trace and critical path sections.\nfunc (*getCriticalPathHandler) buildOutput(\n\ttraceIDStr string,\n\ttrace ptrace.Traces,\n\tcriticalPathSections []criticalpath.Section,\n) types.GetCriticalPathOutput {\n\t// Build a map of spans for quick lookup\n\tspanMap := jptrace.SpanMap(trace, func(span ptrace.Span) string {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go#L81-L117","documentation":"buildQuery parses the user-supplied trace ID string with parseTraceID; a parse failure is wrapped as \"invalid trace_id: <cause>\". The MCP tool requires an exact, well-formed trace ID (e.g. 32 hex chars for a 128-bit ID) to query the trace store.","triggerScenarios":"Calling the get_critical_path tool with a trace_id that is empty (a separate 'trace_id is required' error), non-hexadecimal, wrong length, or otherwise unparseable by parseTraceID.","commonSituations":"LLM/MCP client passes a display ID, span ID, or truncated trace ID copied from a UI; whitespace or URL-encoding artifacts in the string; passing a Jaeger 'traceid:spanid' composite string.","solutions":["Pass the full 128-bit trace ID as lowercase hex (32 characters) from the trace's header, not a span ID or shortened form.","Strip whitespace/quotes and any composite suffixes (e.g. ':spanid') from the ID.","Re-copy the trace ID from the Jaeger UI or the storage record to avoid transcription errors."],"exampleFix":"// before\n{\"trace_id\": \"abc123\"}\n// after\n{\"trace_id\": \"4e7a1f2b3c4d5e6f708192a3b4c5d6e7\"}","handlingStrategy":"validation","validationCode":"func validTraceID(s string) bool {\n    s = strings.TrimSpace(s)\n    if len(s) != 32 && len(s) != 16 { return false }\n    _, err := hex.DecodeString(s)\n    return err == nil\n}\nif !validTraceID(input.TraceID) { return errors.New(\"trace_id must be 16 or 32 hex characters\") }","typeGuard":"func isHexString(s string, l int) bool {\n    return len(s) == l && strings.TrimFunc(strings.ToLower(s), func(r rune) bool {\n        return (r >= '0' && r <= '9') || (r >= 'a' && r <= 'f')\n    }) == \"\"\n}","tryCatchPattern":"out, err := handler.Handle(ctx, input)\nif err != nil && strings.Contains(err.Error(), \"invalid trace_id:\") {\n    return fmt.Errorf(\"supply the full 32-char hex trace ID: %w\", err)\n}","preventionTips":["Copy trace IDs from the Jaeger UI's JSON/raw view, not the URL display string.","For MCP/LLM callers, document that trace_id must be 32 lowercase hex characters.","Trim and normalize IDs before sending them to the tool."],"tags":["validation","trace-id","mcp"],"backgroundTag":"invalid-trace-id","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}