jaegertracing/jaeger · error

start and end time must be set

Error message

start and end time must be set

What it means

ErrStartAndEndTimeNotSet is returned by validateQuery when either StartTimeMin or StartTimeMax in TraceQueryParameters is the zero time.Time. The badger backend requires an explicit time window because it scans keys whose layout encodes start timestamps; an unbounded window is not expressible.

Source

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

)

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

// TraceReader reads traces from the local badger store

View on GitHub (pinned to 806f444784)

Solutions

  1. Always set both StartTimeMin and StartTimeMax, e.g. now-lookback and now.
  2. Add a pre-query defaulting step that fills zero times with your desired window.
  3. For UI/API-driven queries, make start/end required fields in the request schema.

Example fix

// before
q := &spanstore.TraceQueryParameters{ServiceName: "orders"} // zero times
ids, err := reader.FindTraceIDs(ctx, q)
// after
now := time.Now()
q := &spanstore.TraceQueryParameters{ServiceName: "orders", StartTimeMin: now.Add(-time.Hour), StartTimeMax: now}
ids, err := reader.FindTraceIDs(ctx, q)
Defensive patterns

Strategy: validation

Validate before calling

if q != nil && (q.StartTimeMin.IsZero() || q.StartTimeMax.IsZero()) {
	now := time.Now()
	q.StartTimeMin, q.StartTimeMax = now.Add(-time.Hour), now
}

Type guard

func hasExplicitTimeRange(q *spanstore.TraceQueryParameters) bool {
	return q != nil && !q.StartTimeMin.IsZero() && !q.StartTimeMax.IsZero()
}

Try / catch

ids, err := reader.FindTraceIDs(ctx, q)
if errors.Is(err, spanstore.ErrStartAndEndTimeNotSet) {
	return nil, httpError(400, "start and end time are required")
}
if err != nil { return nil, err }

Prevention

When it happens

Trigger: FindTraceIDs/FindTraces with a query struct where StartTimeMin.IsZero() || StartTimeMax.IsZero() — usually a partially-populated struct where the caller set filters but forgot the time bounds.

Common situations: Clients assuming the backend defaults the time range (it does not, unlike some backends); query structs deserialized from JSON missing start/end fields; test code constructing minimal queries.

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/05281456b2772bbd. Report an issue: GitHub.