jaegertracing/jaeger · error

malformed request object

Error message

malformed request object

What it means

ErrMalformedRequestObject is returned by validateQuery when the *spanstore.TraceQueryParameters pointer passed to FindTraces/FindTraceIDs is nil. A nil query object has no bounds or filters at all, so the reader refuses it instead of panicking on field access.

Source

Thrown at internal/storage/v1/badger/spanstore/reader.go:37

	"github.com/jaegertracing/jaeger-idl/model/v1"
	"github.com/jaegertracing/jaeger/internal/storage/v1/api/spanstore"
	"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore"
)

// Most of these errors are common with the ES and Cassandra backends. Each backend has slightly different validation rules.

var (
	// ErrServiceNameNotSet occurs when attempting to query with an empty service name
	ErrServiceNameNotSet = errors.New("service name must be set")

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

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

	// 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")

	// ErrNotSupported during development, don't support every option - yet
	ErrNotSupported = errors.New("this query parameter is not supported yet")

	// ErrInternalConsistencyError indicates internal data consistency issue
	ErrInternalConsistencyError = errors.New("internal data consistency issue")
)

const (
	defaultNumTraces = 100
	sizeOfTraceID    = 16
	encodingTypeBits = 0x0F

View on GitHub (pinned to 806f444784)

Solutions

  1. Always pass a non-nil *spanstore.TraceQueryParameters; use an empty struct for 'match everything recent'.
  2. Check for nil in your caller before invoking the reader and return a client-side validation error.
  3. At an API boundary, default an empty request to &spanstore.TraceQueryParameters{StartTimeMin: ..., StartTimeMax: ...} with sane bounds.

Example fix

// before
ids, err := reader.FindTraceIDs(ctx, nil)
// after
if query == nil {
	query = &spanstore.TraceQueryParameters{
		StartTimeMin: time.Now().Add(-time.Hour),
		StartTimeMax: time.Now(),
	}
}
ids, err := reader.FindTraceIDs(ctx, query)
Defensive patterns

Strategy: validation

Validate before calling

if q == nil {
	return errors.New("trace query parameters must not be nil")
}

Type guard

func isUsableQuery(q *spanstore.TraceQueryParameters) bool {
	return q != nil
}

Try / catch

ids, err := reader.FindTraceIDs(ctx, q)
if errors.Is(err, spanstore.ErrMalformedRequestObject) {
	return nil, httpError(400, "missing query parameters")
}
if err != nil { return nil, err }

Prevention

When it happens

Trigger: Calling FindTraceIDs(ctx, nil) or FindTraces(ctx, nil) directly — most often from hand-written integrations or test code that builds the request conditionally and skips the nil case.

Common situations: Wrappers that pass through a decoded request body which failed to bind; generic adapters constructing the params only when filters exist; unit tests passing nil expecting an empty result.

Understand the failure class

Related errors


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