{"record":{"id":"b0920bec3467a439","repo":"jaegertracing/jaeger","slug":"failed-to-get-trace-w-b0920b","errorCode":null,"errorMessage":"failed to get trace: %w","messagePattern":"failed to get trace: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_span_details.go","lineNumber":81,"sourceCode":"\t// Create span ID set for efficient lookup\n\tspanIDSet := make(map[string]struct{}, len(canonicalSpanIDs))\n\tfor _, spanID := range canonicalSpanIDs {\n\t\tspanIDSet[spanID] = struct{}{}\n\t}\n\n\ttracesIter := h.queryService.GetTraces(ctx, params)\n\n\t// Wrap with AggregateTraces to ensure each ptrace.Traces contains a complete trace\n\taggregatedIter := jptrace.AggregateTraces(tracesIter)\n\n\t// Collect spans matching the requested span IDs\n\tvar spanDetails []types.SpanDetail\n\ttraceFound := false\n\n\tfor trace, err := range aggregatedIter {\n\t\tif err != nil {\n\t\t\t// For singular lookups, return error directly\n\t\t\treturn nil, types.GetSpanDetailsOutput{}, fmt.Errorf(\"failed to get trace: %w\", err)\n\t\t}\n\n\t\ttraceFound = true\n\n\t\t// Iterate through all spans in the trace\n\t\tfor pos, span := range jptrace.SpanIter(trace) {\n\t\t\tspanIDStr := span.SpanID().String()\n\n\t\t\t// Check if this span ID is in the requested set\n\t\t\tif _, found := spanIDSet[spanIDStr]; found {\n\t\t\t\tdetail := buildSpanDetail(pos, span)\n\t\t\t\tspanDetails = append(spanDetails, detail)\n\n\t\t\t\t// Remove from set to track which spans we've found\n\t\t\t\tdelete(spanIDSet, spanIDStr)\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_span_details.go#L63-L99","documentation":"In the get_span_details handler, the aggregated trace iterator from the query service can return a per-trace error. For a singular trace lookup (specific trace_id), such an error is fatal and is wrapped with \"failed to get trace\". It represents a trace-retrieval failure at the storage layer (or a not-found surfaced as an error), not malformed input.","triggerScenarios":"Requesting span details for a trace_id whose fetch fails: trace not found where backend returns an error, storage read error, context cancellation mid-iteration, or partial/aggregated iteration failure while walking returned traces.","commonSituations":"Trace expired and purged by retention but still cached in a UI lookup; Elasticsearch shard unavailable; trace ID from another environment/backend queried against the wrong jaeger-query instance.","solutions":["Check the wrapped %w error to distinguish not-found from storage failure.","Verify the trace_id corresponds to this Jaeger backend and retention window.","Check storage health (index/shard status, connectivity) in jaeger-query logs.","Retry the request; for persistent not-found, confirm with trace search that the trace exists."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"func validTraceRef(traceID string) bool {\n\treturn len(traceID) == 32 && isHex(traceID) // reject obviously invalid ids before querying\n}","typeGuard":null,"tryCatchPattern":"out, _, err := handler.Handle(ctx, req, input)\nif err != nil && strings.Contains(err.Error(), \"failed to get trace\") {\n\tif strings.Contains(err.Error(), \"not found\") {\n\t\treturn nil // treat as missing trace, not a failure\n\t}\n\tlog.Printf(\"trace fetch failed: %v\", err) // check storage health and retry\n}","preventionTips":["Confirm the trace ID exists (via search) in the same backend you query.","Stay within the retention window; purged traces are unrecoverable.","Handle not-found distinctly from infrastructure errors.","Monitor storage shard/index health for the trace store."],"tags":["storage","trace-lookup","jaeger","mcp"],"backgroundTag":"trace-not-found","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}