{"record":{"id":"904c4644c2520fca","repo":"jaegertracing/jaeger","slug":"trace-not-found","errorCode":null,"errorMessage":"trace not found","messagePattern":"trace not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go","lineNumber":75,"sourceCode":"\n\t// Wrap with AggregateTraces to ensure each ptrace.Traces contains a complete trace\n\taggregatedIter := jptrace.AggregateTraces(tracesIter)\n\n\tvar trace ptrace.Traces\n\ttraceFound := false\n\n\tfor t, err := range aggregatedIter {\n\t\tif err != nil {\n\t\t\treturn nil, types.GetCriticalPathOutput{}, fmt.Errorf(\"failed to get trace: %w\", err)\n\t\t}\n\n\t\ttraceFound = true\n\t\ttrace = t\n\t\tbreak // We expect only one trace since we're querying by a single trace ID\n\t}\n\n\tif !traceFound {\n\t\treturn nil, types.GetCriticalPathOutput{}, errors.New(\"trace not found\")\n\t}\n\n\t// Compute critical path\n\tcriticalPathSections, err := criticalpath.ComputeCriticalPathFromTraces(trace)\n\tif err != nil {\n\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 == \"\" {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go#L57-L93","documentation":"The Jaeger MCP get_critical_path handler queries the trace store by a single trace ID and requires exactly one matching trace. This error is thrown when GetTraces returns results but none match the requested trace ID (traceFound stays false), meaning the trace does not exist in storage. It surfaces as an MCP tool error to the caller, not a panic.","triggerScenarios":"Calling the get_critical_path MCP tool with a trace_id that is valid hex but absent from the Jaeger storage backend; the query service returns zero traces or traces with a different ID, so the loop over results never sets traceFound.","commonSituations":"Copy-pasted trace ID from another environment (dev vs prod); trace aged out of retention and was dropped by storage TTL; sampling discarded the trace so it was never stored; typo in one hex digit; querying a replica that has not yet received the span.","solutions":["Verify the trace ID exists by fetching it first (get_trace / query API) before computing the critical path","Check you are pointing the Jaeger query service at the same storage backend the trace was written to","Confirm the trace is within the storage retention window and was not dropped by sampling"],"exampleFix":"// before\ncriticalPath, err := criticalPathTool.Handle(ctx, req, types.GetCriticalPathInput{TraceID: id})\n// after\nif _, err := getTraceTool.Handle(ctx, req, types.GetTraceInput{TraceID: id}); err != nil {\n    return nil, fmt.Errorf(\"trace %s not found in storage: %w\", id, err)\n}\ncriticalPath, err := criticalPathTool.Handle(ctx, req, types.GetCriticalPathInput{TraceID: id})","handlingStrategy":"validation","validationCode":"func traceIDLooksValid(id string) bool {\n    if id == \"\" { return false }\n    _, err := hex.DecodeString(id)\n    return err == nil && (len(id) == 16 || len(id) == 32)\n}\nif !traceIDLooksValid(input.TraceID) { /* don't call; resolve a real ID */ }","typeGuard":null,"tryCatchPattern":"out, err := handler.Handle(ctx, req, input)\nif err != nil {\n    if strings.Contains(err.Error(), \"trace not found\") {\n        // fall back: re-query the trace list or notify user the ID is absent\n    }\n    return err\n}","preventionTips":["Look up the trace (get_trace) before computing derived analytics like critical path","Keep trace IDs in one canonical lowercase-hex form end-to-end","Check sampling and retention policies for the environment you query","Verify query service and ingestion share the same storage backend"],"tags":["jaeger","mcp","trace-not-found","storage"],"backgroundTag":"trace-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}