jaegertracing/jaeger · error

trace_id is required

Error message

trace_id is required

What it means

The buildQuery helper of the get_critical_path MCP handler validates input before converting GetCriticalPathInput to querysvc.GetTraceParams. When input.TraceID is the empty string it cannot form a trace lookup, so it fails fast with this sentinel error instead of issuing a doomed query.

Source

Thrown at cmd/jaeger/internal/extension/jaegerquery/internal/mcptools/internal/handlers/get_critical_path.go:94

	}

	// Compute critical path
	criticalPathSections, err := criticalpath.ComputeCriticalPathFromTraces(trace)
	if err != nil {
		return nil, types.GetCriticalPathOutput{}, fmt.Errorf("failed to compute critical path: %w", err)
	}

	// Build output
	output := h.buildOutput(input.TraceID, trace, criticalPathSections)

	return nil, output, nil
}

// buildQuery converts GetCriticalPathInput to querysvc.GetTraceParams.
func (*getCriticalPathHandler) buildQuery(input types.GetCriticalPathInput) (querysvc.GetTraceParams, error) {
	// Validate input
	if input.TraceID == "" {
		return querysvc.GetTraceParams{}, errors.New("trace_id is required")
	}

	traceID, err := parseTraceID(input.TraceID)
	if err != nil {
		return querysvc.GetTraceParams{}, fmt.Errorf("invalid trace_id: %w", err)
	}

	return querysvc.GetTraceParams{
		TraceIDs: []tracestore.GetTraceParams{
			{TraceID: traceID},
		},
		RawTraces: false, // We want adjusted traces
	}, nil
}

// buildOutput constructs the GetCriticalPathOutput from the trace and critical path sections.
func (*getCriticalPathHandler) buildOutput(
	traceIDStr string,

View on GitHub (pinned to 806f444784)

Solutions

  1. Always populate trace_id in the tool input before calling get_critical_path
  2. Enforce required-argument validation in the MCP client/tool schema so the call is rejected before reaching the handler
  3. If the trace ID comes from a prior tool step, check it is non-empty before chaining

Example fix

// before
input := types.GetCriticalPathInput{TraceID: traceIDFromStep} // may be ""
// after
if traceIDFromStep == "" {
    return fmt.Errorf("no trace ID available from previous step")
}
input := types.GetCriticalPathInput{TraceID: traceIDFromStep}
Defensive patterns

Strategy: validation

Validate before calling

if input.TraceID == "" {
    return errors.New("trace_id is required before calling get_critical_path")
}

Try / catch

out, err := handler.Handle(ctx, req, input)
if err != nil && strings.Contains(err.Error(), "trace_id is required") {
    return fmt.Errorf("caller bug: get_critical_path invoked without trace_id")
}

Prevention

When it happens

Trigger: Invoking the get_critical_path MCP tool with TraceID omitted or set to "" — e.g. an LLM client filling the tool arguments without the required trace_id field.

Common situations: MCP client schema not enforcing required fields; prompt-generated arguments missing the field; empty variable interpolated into the tool input from an upstream step that produced no trace.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jaegertracing/jaeger@806f444784 (2026-09-01). Data as JSON: /api/errors/28d06a2c52dc0c40. Report an issue: GitHub.