{"record":{"id":"038be393b681a518","repo":"jaegertracing/jaeger","slug":"min-duration-is-above-max","errorCode":null,"errorMessage":"min duration is above max","messagePattern":"min duration is above max","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/storage/v1/badger/spanstore/reader.go","lineNumber":34,"sourceCode":"\t\"github.com/dgraph-io/badger/v4\"\n\t\"golang.org/x/exp/maps\"\n\n\t\"github.com/jaegertracing/jaeger-idl/model/v1\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v1/api/spanstore\"\n\t\"github.com/jaegertracing/jaeger/internal/storage/v2/api/tracestore\"\n)\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 (","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/badger/spanstore/reader.go#L16-L52","documentation":"ErrDurationMinGreaterThanMax is returned by validateQuery when TraceQueryParameters sets both DurationMin and DurationMax with DurationMin > DurationMax. The duration filter is implemented as a hash-join over index entries, so a contradictory duration window is rejected during validation.","triggerScenarios":"FindTraceIDs/FindTraces with DurationMin and DurationMax both non-zero and DurationMin > DurationMax — e.g. 'at least 5s' combined with 'at most 2s'.","commonSituations":"UI duration filters where the min/max inputs are filled in the wrong boxes; programmatic callers swapping duration units (ms vs s) so min numerically exceeds max; copy-paste of filter values.","solutions":["Correct the values so DurationMin <= DurationMax before querying.","Only set both fields when a bounded range is intended; leave DurationMax (or DurationMin) at 0 for one-sided filters.","Normalize units (use time.Duration everywhere) so ms/s confusion cannot invert the range."],"exampleFix":"// before\nq := &spanstore.TraceQueryParameters{DurationMin: 5 * time.Second, DurationMax: 2 * time.Second}\n// after\nq := &spanstore.TraceQueryParameters{DurationMin: 2 * time.Second, DurationMax: 5 * time.Second}","handlingStrategy":"validation","validationCode":"if q != nil && q.DurationMin != 0 && q.DurationMax != 0 && q.DurationMin > q.DurationMax {\n\treturn errors.New(\"DurationMin must be <= DurationMax\")\n}","typeGuard":"func hasValidDurationRange(q *spanstore.TraceQueryParameters) bool {\n\treturn q == nil || q.DurationMin == 0 || q.DurationMax == 0 || q.DurationMin <= q.DurationMax\n}","tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrDurationMinGreaterThanMax) {\n\treturn nil, httpError(400, \"duration filter is inverted: min exceeds max\")\n}\nif err != nil { return nil, err }","preventionTips":["Use time.Duration (or a single unit like ms) end-to-end so unit confusion cannot invert the range.","Clamp or swap min/max in the shared query-builder before submission.","Constrain duration min/max inputs in the UI (min <= max)."],"tags":["go","badger","query-validation","duration-filter"],"backgroundTag":"invalid-time-range","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}