{"record":{"id":"d9018e7ba4813bcb","repo":"jaegertracing/jaeger","slug":"duration-minimum-is-above-maximum","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/v1/cassandra/spanstore/reader.go","lineNumber":72,"sourceCode":"\t\tFROM duration_index\n\t\tWHERE bucket = ? AND service_name = ? AND operation_name = ? AND duration >= ? AND duration <= ?\n\t\tLIMIT ?`\n\n\tdefaultNumTraces = 100\n\t// limitMultiple exists because many spans that are returned from indices can have the same trace, limitMultiple increases\n\t// the number of responses from the index, so we can respect the user's limit value they provided.\n\tlimitMultiple = 3\n)\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(\"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// ErrDurationAndTagQueryNotSupported occurs when duration and tags are both set\n\tErrDurationAndTagQueryNotSupported = errors.New(\"cannot query for duration and tags simultaneously\")\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\ntype serviceNamesReader func() ([]string, error)\n\ntype operationNamesReader func(query tracestore.OperationQueryParams) ([]tracestore.Operation, error)\n\ntype spanReaderMetrics struct {\n\treadTraces                 *casmetrics.Table\n\tqueryTrace                 *casmetrics.Table","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/cassandra/spanstore/reader.go#L54-L90","documentation":"ErrDurationMinGreaterThanMax is returned by validateQuery when DurationMin > DurationMax in the TraceQueryParams. Duration filters translate into CQL range conditions; an inverted duration range can never match, so the reader rejects the query with this sentinel error before touching the database.","triggerScenarios":"FindTraces/FindTraceIDs called with TraceQueryParams where both DurationMin and DurationMax are non-zero and DurationMin > DurationMax.","commonSituations":"A UI letting users type min/max duration without ordering enforcement; a client swapping fields when constructing the request; programmatic callers reusing a params struct and only updating one of the two duration fields.","solutions":["Swap DurationMin and DurationMax so DurationMin <= DurationMax before the call.","Validate/normalize the duration range at the API boundary and reject or auto-correct inverted ranges.","Check code that mutates the params struct to ensure both duration bounds are updated consistently."],"exampleFix":"// before\nq.DurationMin, q.DurationMax = 5*time.Second, 1*time.Second\n// after\nif q.DurationMin > q.DurationMax { q.DurationMin, q.DurationMax = q.DurationMax, q.DurationMin }","handlingStrategy":"validation","validationCode":"if q.DurationMin != 0 && q.DurationMax != 0 && q.DurationMin > q.DurationMax {\n    return errors.New(\"duration min must be <= duration max\")\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrDurationMinGreaterThanMax) {\n    return errors.New(\"invalid duration range\")\n}","preventionTips":["Swap/normalize min/max duration in one shared validation helper.","Clamp or reorder user-provided duration inputs at the API boundary.","Update both duration fields together when reusing params structs."],"tags":["cassandra","query-validation","duration-filter"],"backgroundTag":"invalid-duration-range","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}