jaegertracing/jaeger · error

malformed request object

Error message

malformed request object

What it means

ErrMalformedRequestObject is a sentinel error returned by validateQuery when the request passed to the reader is nil. The Elasticsearch trace reader requires a non-nil query object to build its search request, so a nil input is reported as a malformed request instead of panicking with a nil dereference.

Source

Thrown at internal/storage/v2/elasticsearch/tracestore/core/reader.go:62

	nestedLogFieldsField   = "logs.fields"
	tagKeyField            = "key"
	tagValueField          = "value"
	errorTag               = "error"

	defaultSearchDepth = 100

	DawnOfTimeSpanAge = time.Hour * 24 * 365 * 50
)

var (
	// ErrStartTimeMinGreaterThanMax occurs when start time min is above start time max
	ErrStartTimeMinGreaterThanMax = errors.New("start Time Minimum is above Maximum")

	// ErrDurationMinGreaterThanMax occurs when duration min is above duration max
	ErrDurationMinGreaterThanMax = errors.New("duration Minimum is above Maximum")

	// ErrMalformedRequestObject occurs when a request object is nil
	ErrMalformedRequestObject = errors.New("malformed request object")

	// ErrStartAndEndTimeNotSet occurs when start time and end time are not set
	ErrStartAndEndTimeNotSet = errors.New("start and End Time must be set")

	// ErrUnableToFindTraceIDAggregation occurs when an aggregation query for TraceIDs fail.
	ErrUnableToFindTraceIDAggregation = errors.New("could not find aggregation of traceIDs")

	defaultMaxDuration = model.DurationAsMicroseconds(time.Hour * 24)

	objectTagFieldList = []string{objectTagsField, objectProcessTagsField}

	nestedTagFieldList = []string{nestedTagsField, nestedProcessTagsField, nestedLogFieldsField}

	_ Reader = (*SpanReader)(nil) // check API conformance
)

// Time-range design (referenced as "timeRangeDesign" in comments below):
//

View on GitHub (pinned to 806f444784)

Solutions

  1. Pass a non-nil query object (e.g. &v2api.TraceQueryParameters{...}) to FindTraceIDs/FindTraces.
  2. Check for nil in your caller before calling the reader and handle it as a client error.
  3. If the query may legitimately be empty, pass a zero-value struct instead of nil.

Example fix

// before
traceIDs, err := reader.FindTraceIDs(ctx, nil)
// after
if query == nil { return nil, ErrMalformedRequestObject }
traceIDs, err := reader.FindTraceIDs(ctx, query)
Defensive patterns

Strategy: type-guard

Validate before calling

if query == nil {
    return fmt.Errorf("query must be provided: %w", core.ErrMalformedRequestObject)
}

Type guard

func hasQuery(q *api.TraceQueryParameters) bool { return q != nil }

if !hasQuery(query) { /* treat as client error */ }

Try / catch

traces, err := reader.FindTraces(ctx, query)
if errors.Is(err, core.ErrMalformedRequestObject) {
    return http.StatusBadRequest // nil request
}

Prevention

When it happens

Trigger: Calling reader.FindTraceIDs(ctx, nil) or FindTraces(ctx, nil) with a nil query/params struct. validateQuery checks for the nil object first and returns this error.

Common situations: Constructing the query in a variable that failed to initialize (early error path left it nil); wiring a generic query handler that passes through a nil pointer from deserialization; tests forgetting to populate parameters.

Understand the failure class

Related errors


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