{"record":{"id":"1339f1960c4679d5","repo":"SigNoz/signoz","slug":"span-not-found","errorCode":null,"errorMessage":"span not found","messagePattern":"span not found","errorType":"validation","errorClass":null,"httpStatus":404,"severity":"error","filePath":"pkg/query-service/traces/smart/trace.go","lineNumber":64,"sourceCode":"\t// If the target span is not found, return span not found error\n\tif targetSpan == nil {\n\t\treturn nil, errors.New(\"span not found\")\n\t}","sourceCodeStart":null,"sourceCodeEnd":null,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/traces/smart/trace.go#L64","documentation":"Thrown by GetSpanDetails in the smart traces module when the requested spanId cannot be located in the trace's span trees after a breadth-first search from every root span. The trace was found, but the specific span within it was not.","triggerScenarios":"Calling the span-details API with a spanId that does not belong to the supplied traceId, a stale spanId from before trace rollup/sampling, or a span whose parent chain is broken so it never attaches to a root tree (orphan span).","commonSituations":"UI deep-links to a span captured before retention/rollup removed it; copying spanId across environments (dev spanId against prod trace); tail-sampling dropping intermediate spans so BFS from roots never reaches the target.","solutions":["Verify the spanId actually belongs to the given traceId by listing the trace's spans first","Re-fetch the trace and use a spanId returned in that fresh response","If spans are consistently missing, check sampling/rollup configuration for dropped intermediate spans"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"trace, err := api.GetTrace(ctx, traceID)\nif err != nil { return err }\nfound := false\nfor _, s := range trace.Spans {\n    if s.SpanID == spanID { found = true; break }\n}\nif !found { return fmt.Errorf(\"span %s not in trace %s\", spanID, traceID) }","typeGuard":null,"tryCatchPattern":"details, err := api.GetSpanDetails(ctx, traceID, spanID)\nif err != nil {\n    if strings.Contains(err.Error(), \"span not found\") {\n        // refresh trace or fall back to trace-level view\n        return showTraceView(traceID)\n    }\n    return err\n}","preventionTips":["Always take spanIds from a fresh trace fetch, not stored links","Guard deep links with a trace existence check","Monitor sampling config if orphan spans recur"],"tags":["traces","opentelemetry","span-not-found","distributed-tracing"],"backgroundTag":"trace-span-not-found","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}