{"record":{"id":"d3383508ef78e119","repo":"jaegertracing/jaeger","slug":"duration-minimum-is-above-maximum-d33835","errorCode":null,"errorMessage":"duration Minimum is above Maximum","messagePattern":"duration Minimum is above Maximum","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v2/elasticsearch/tracestore/core/reader.go","lineNumber":59,"sourceCode":"\tobjectProcessTagsField = \"process.tag\"\n\tnestedTagsField        = \"tags\"\n\tnestedProcessTagsField = \"process.tags\"\n\tnestedLogFieldsField   = \"logs.fields\"\n\ttagKeyField            = \"key\"\n\ttagValueField          = \"value\"\n\terrorTag               = \"error\"\n\n\tdefaultSearchDepth = 100\n\n\tDawnOfTimeSpanAge = time.Hour * 24 * 365 * 50\n)\n\nvar (\n\t// ErrStartTimeMinGreaterThanMax occurs when start time min is above start time max\n\tErrStartTimeMinGreaterThanMax = errors.New(\"start Time Minimum is above Maximum\")\n\n\t// ErrDurationMinGreaterThanMax occurs when duration min is above duration max\n\tErrDurationMinGreaterThanMax = errors.New(\"duration Minimum is above Maximum\")\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\tdefaultMaxDuration = model.DurationAsMicroseconds(time.Hour * 24)\n\n\tobjectTagFieldList = []string{objectTagsField, objectProcessTagsField}\n\n\tnestedTagFieldList = []string{nestedTagsField, nestedProcessTagsField, nestedLogFieldsField}\n\n\t_ Reader = (*SpanReader)(nil) // check API conformance\n)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/elasticsearch/tracestore/core/reader.go#L41-L77","documentation":"ErrDurationMinGreaterThanMax is a sentinel error returned by validateQuery when a trace query's minimum duration is greater than its maximum duration. Such a range filter (duration_min > duration_max) can never match any span, so the reader rejects it before querying Elasticsearch. It is asserted in TestTraceQueryParameterValidation as part of the documented validation contract.","triggerScenarios":"Calling reader.FindTraceIDs/FindTraces with TraceQueryParameters where DurationMin > DurationMax (e.g. DurationMin=1h, DurationMax=1m). validateQuery performs this comparison after the start-time checks and returns this error.","commonSituations":"UIs letting users set 'slower than X' and 'faster than Y' bounds without checking ordering; unit mix-ups (milliseconds vs microseconds) producing inverted bounds; copy-paste errors when filling query structs.","solutions":["Swap the values so DurationMin <= DurationMax.","Validate the duration ordering in your caller before building TraceQueryParameters.","If only one bound is needed, leave the other at its zero value instead of duplicating a bound."],"exampleFix":"// before\nparams := v2api.TraceQueryParameters{DurationMin: 3600e6, DurationMax: 60e6}\n// after\nif params.DurationMin > params.DurationMax {\n    params.DurationMin, params.DurationMax = params.DurationMax, params.DurationMin\n}","handlingStrategy":"validation","validationCode":"func validateDurationRange(p *api.TraceQueryParameters) error {\n    if p.DurationMin > 0 && p.DurationMax > 0 && p.DurationMin > p.DurationMax {\n        p.DurationMin, p.DurationMax = p.DurationMax, p.DurationMin\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, query)\nif errors.Is(err, core.ErrDurationMinGreaterThanMax) {\n    return http.StatusBadRequest // inverted duration bounds\n}","preventionTips":["Clamp or swap duration bounds at the boundary where user input enters your code.","Keep durations in one unit (e.g. time.Duration) until serialization to avoid unit mix-ups.","Set only the bound you need; leave the other zero instead of duplicating."],"tags":["elasticsearch","query-validation","duration-range"],"backgroundTag":"invalid-query-parameter","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}