{"record":{"id":"e0297c342f25176c","repo":"dagger/dagger","slug":"no-span-q-in-this-trace","errorCode":null,"errorMessage":"no span %q in this trace","messagePattern":"no span %q in this trace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/trace_target.go","lineNumber":105,"sourceCode":"//     started matching span.\n//\n// Most-recent-wins because a name is how a reader refers to a check or test\n// they just saw run: when a name matched several spans (a retried check, a\n// test case run under more than one suite), the latest one is the one they\n// mean.\nfunc resolveTraceTargetIn(db *dagui.DB, target traceTarget) (string, error) {\n\tswitch {\n\tcase target.empty():\n\t\treturn \"\", fmt.Errorf(\"ReadTrace needs a target: pass span (a hex span ID), \" +\n\t\t\t\"check (a check name, e.g. \\\"lint:check\\\"), or test (a test case or suite name)\")\n\n\tcase target.Span != \"\":\n\t\tid, err := trace.SpanIDFromHex(target.Span)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"invalid span ID %q: %w\", target.Span, err)\n\t\t}\n\t\tif _, ok := db.Spans.Map[dagui.SpanID{SpanID: id}]; !ok {\n\t\t\treturn \"\", fmt.Errorf(\"no span %q in this trace\", target.Span)\n\t\t}\n\t\treturn target.Span, nil\n\n\tcase target.Check != \"\":\n\t\t// Resolve by scanning span check names directly, NOT via\n\t\t// DB.SurfacedChecks: surfacing answers \"should this check be listed in\n\t\t// a report\", which depends on Boundary/Encapsulate containment -- and a\n\t\t// check run inside an LLM tool call always has a Boundary ancestor (the\n\t\t// tool-call display span). A name lookup must not inherit that: the\n\t\t// reader is naming something it just saw run.\n\t\tnames := map[string]bool{}\n\t\tvar best *dagui.Span\n\t\tfor span := range db.Spans.Iter() {\n\t\t\tif span.CheckName == \"\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tnames[span.CheckName] = true\n\t\t\tif span.CheckName != target.Check {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/trace_target.go#L87-L123","documentation":"resolveTraceTargetIn parsed the target's span ID but no span with that hex ID exists in the loaded trace's dagui DB. The user-supplied span selector points outside the trace being read (wrong trace, stale span ID, or the span was never recorded).","triggerScenarios":"Calling resolveTraceTarget with a syntactically valid span ID that belongs to a different trace or was captured in another session.","commonSituations":"Pointing ReadTrace at trace A while copying a span ID from trace B; an old span ID from a previous engine run that is not in the current trace file.","solutions":["Confirm you loaded the trace file that actually contains this span ID","Use the check or test name form to resolve by name within the current trace","List available spans from the report session and pick one present in it"],"exampleFix":"// before\nid, err := resolveTraceTarget(db, traceTarget{Span: oldSpanID})\n// after\nif _, ok := db.Spans.Map[dagui.SpanID{SpanID: sid}]; !ok {\n\treturn fmt.Errorf(\"span %s not found; did you load the right trace?\", sid)\n}\nid, err := resolveTraceTarget(db, traceTarget{Span: oldSpanID})","handlingStrategy":"validation","validationCode":"sid, _ := trace.SpanIDFromHex(spanArg)\nif _, ok := db.Spans.Map[dagui.SpanID{SpanID: sid}]; !ok {\n\treturn fmt.Errorf(\"span %s not in loaded trace\", spanArg)\n}","typeGuard":null,"tryCatchPattern":"id, err := resolveTraceTarget(db, target)\nif err != nil && strings.Contains(err.Error(), \"no span\") {\n\t// list spans from db.Spans.Map and prompt for a valid one\n}","preventionTips":["Confirm the loaded trace file matches the run the span came from","List available span IDs from the session before targeting one","Avoid caching span IDs across different trace loads"],"tags":["tracing","lookup","not-found"],"backgroundTag":"span-not-found","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}