{"record":{"id":"05281456b2772bbd","repo":"jaegertracing/jaeger","slug":"start-and-end-time-must-be-set","errorCode":null,"errorMessage":"start and end time must be set","messagePattern":"start and end time must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/badger/spanstore/reader.go","lineNumber":40,"sourceCode":")\n\n// Most of these errors are common with the ES and Cassandra backends. Each backend has slightly different validation rules.\n\nvar (\n\t// ErrServiceNameNotSet occurs when attempting to query with an empty service name\n\tErrServiceNameNotSet = errors.New(\"service name must be set\")\n\n\t// ErrStartTimeMinGreaterThanMax occurs when start time min is above start time max\n\tErrStartTimeMinGreaterThanMax = errors.New(\"min start time is above max\")\n\n\t// ErrDurationMinGreaterThanMax occurs when duration min is above duration max\n\tErrDurationMinGreaterThanMax = errors.New(\"min duration is above max\")\n\n\t// ErrMalformedRequestObject occurs when a request object is nil\n\tErrMalformedRequestObject = errors.New(\"malformed request object\")\n\n\t// ErrStartAndEndTimeNotSet occurs when start time and end time are not set\n\tErrStartAndEndTimeNotSet = errors.New(\"start and end time must be set\")\n\n\t// ErrUnableToFindTraceIDAggregation occurs when an aggregation query for TraceIDs fail.\n\tErrUnableToFindTraceIDAggregation = errors.New(\"could not find aggregation of traceIDs\")\n\n\t// ErrNotSupported during development, don't support every option - yet\n\tErrNotSupported = errors.New(\"this query parameter is not supported yet\")\n\n\t// ErrInternalConsistencyError indicates internal data consistency issue\n\tErrInternalConsistencyError = errors.New(\"internal data consistency issue\")\n)\n\nconst (\n\tdefaultNumTraces = 100\n\tsizeOfTraceID    = 16\n\tencodingTypeBits = 0x0F\n)\n\n// TraceReader reads traces from the local badger store","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/badger/spanstore/reader.go#L22-L58","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Always set both StartTimeMin and StartTimeMax, e.g. now-lookback and now.","Add a pre-query defaulting step that fills zero times with your desired window.","For UI/API-driven queries, make start/end required fields in the request schema."],"exampleFix":"// before\nq := &spanstore.TraceQueryParameters{ServiceName: \"orders\"} // zero times\nids, err := reader.FindTraceIDs(ctx, q)\n// after\nnow := time.Now()\nq := &spanstore.TraceQueryParameters{ServiceName: \"orders\", StartTimeMin: now.Add(-time.Hour), StartTimeMax: now}\nids, err := reader.FindTraceIDs(ctx, q)","handlingStrategy":"validation","validationCode":"if q != nil && (q.StartTimeMin.IsZero() || q.StartTimeMax.IsZero()) {\n\tnow := time.Now()\n\tq.StartTimeMin, q.StartTimeMax = now.Add(-time.Hour), now\n}","typeGuard":"func hasExplicitTimeRange(q *spanstore.TraceQueryParameters) bool {\n\treturn q != nil && !q.StartTimeMin.IsZero() && !q.StartTimeMax.IsZero()\n}","tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrStartAndEndTimeNotSet) {\n\treturn nil, httpError(400, \"start and end time are required\")\n}\nif err != nil { return nil, err }","preventionTips":["Fill zero StartTimeMin/StartTimeMax with a default lookback in a shared query-normalizer.","Make start/end required fields in API request schemas and validate on ingest.","Remember badger (unlike some backends) does not default the time window — always set it explicitly.","Test query construction from JSON payloads where time fields may be absent."],"tags":["go","badger","query-validation","time-range"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}