{"record":{"id":"82a456bc0b7a8e12","repo":"jaegertracing/jaeger","slug":"trace-id-is-required-82a456","errorCode":null,"errorMessage":"trace_id is required","messagePattern":"trace_id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_trace_topology.go","lineNumber":110,"sourceCode":"\n\tif !traceFound {\n\t\treturn nil, types.GetTraceTopologyOutput{}, errors.New(\"trace not found\")\n\t}\n\n\t// Build the flat topology list from the collected spans\n\toutput := types.GetTraceTopologyOutput{\n\t\tTraceID: input.TraceID,\n\t\tSpans:   h.buildFlatTopology(spans, input.Depth),\n\t}\n\n\treturn nil, output, nil\n}\n\n// buildQuery converts GetTraceTopologyInput to querysvc.GetTraceParams.\nfunc (*getTraceTopologyHandler) buildQuery(input types.GetTraceTopologyInput) (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// extractRawSpan extracts minimal span information needed for topology.\nfunc extractRawSpan(pos jptrace.SpanIterPos, span ptrace.Span) rawSpan {\n\t// Get service name from resource attributes","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_trace_topology.go#L92-L128","documentation":"buildQuery validates the GetTraceTopologyInput before converting it to querysvc.GetTraceParams. Since a topology cannot be computed without a trace, an empty TraceID string is rejected immediately with \"trace_id is required\". This is a plain input-validation error raised before any storage call is made.","triggerScenarios":"Invoking the get_trace_topology MCP handler with a GetTraceTopologyInput whose TraceID field is the empty string (field omitted, JSON key misspelled so it unmarshals to zero value, or the caller passed an unset variable).","commonSituations":"MCP clients omitting the trace_id argument; constructing the input struct programmatically and forgetting to set TraceID; an upstream step that failed silently and left the ID blank.","solutions":["Set the trace_id argument on the get_trace_topology call to a non-empty trace ID.","If the ID comes from a prior tool call or pipeline step, check that step actually produced it before calling this tool.","Check the JSON key casing in the request payload (trace_id vs TraceID) so it unmarshals into the TraceID field."],"exampleFix":"// before\ninput := types.GetTraceTopologyInput{} // TraceID empty\n// after\nif input.TraceID == \"\" {\n    return fmt.Errorf(\"get_trace_topology: trace_id must be provided\")\n}\ninput := types.GetTraceTopologyInput{TraceID: traceIDFromParentStep}","handlingStrategy":"validation","validationCode":"if input.TraceID == \"\" {\n    return errors.New(\"get_trace_topology: trace_id is required\")\n}","typeGuard":"func hasTraceID(in types.GetTraceTopologyInput) bool { return in.TraceID != \"\" }","tryCatchPattern":"out, err := handler.Handle(ctx, in)\nif err != nil {\n    if strings.Contains(err.Error(), \"trace_id is required\") {\n        return fmt.Errorf(\"caller bug: GetTraceTopologyInput.TraceID was not set: %w\", err)\n    }\n    return err\n}","preventionTips":["Construct inputs with explicit field names, never positional/zero-value literals.","Make the upstream step that produces the trace ID return an error when it has none.","Use JSON key casing consistent with the Go field tags (trace_id) in payloads."],"tags":["mcp","input-validation","missing-field"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}