{"record":{"id":"6b88016f6703fc80","repo":"jaegertracing/jaeger","slug":"start-time-minimum-is-above-maximum","errorCode":null,"errorMessage":"start Time Minimum is above Maximum","messagePattern":"start Time Minimum is above Maximum","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/v1/cassandra/spanstore/reader.go","lineNumber":69,"sourceCode":"\t\tLIMIT ?`\n\tqueryByDuration = `\n\t\tSELECT trace_id\n\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","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v1/cassandra/spanstore/reader.go#L51-L87","documentation":"ErrStartTimeMinGreaterThanMax is returned by validateQuery when the query's StartTimeMax is before StartTimeMin. The Cassandra reader builds a time-range predicate for the search; an inverted range can never match rows, so the reader rejects it up front with this descriptive sentinel error.","triggerScenarios":"FindTraces/FindTraceIDs called with TraceQueryParams where p.StartTimeMax.Before(p.StartTimeMin) is true — e.g. swapped start/end timestamps, or a timezone/unit conversion bug that flips the range.","commonSituations":"A UI date-range picker emitting reversed boundaries; a client computing 'last N hours' with min/max assigned in the wrong order; cross-timezone clients sending local-time values misordered after conversion to UTC.","solutions":["Swap the values so StartTimeMin <= StartTimeMax before calling FindTraces.","Add caller-side validation: if StartTimeMax.Before(StartTimeMin), return a 400-style error to the client.","Audit timestamp assignment/conversion code (unit and timezone) that produces the range."],"exampleFix":"// before\nq.StartTimeMin, q.StartTimeMax = end, start\n// after\nif start.After(end) { start, end = end, start }\nq.StartTimeMin, q.StartTimeMax = start, end","handlingStrategy":"validation","validationCode":"if !q.StartTimeMax.Before(q.StartTimeMin) == false || q.StartTimeMin.After(q.StartTimeMax) {\n    return errors.New(\"start time min must be <= start time max\")\n}","typeGuard":null,"tryCatchPattern":"ids, err := reader.FindTraceIDs(ctx, q)\nif errors.Is(err, spanstore.ErrStartTimeMinGreaterThanMax) {\n    return errors.New(\"invalid time range: min is after max\")\n}","preventionTips":["Normalize the range (swap if inverted) in a single helper before constructing TraceQueryParams.","Enforce ordering in UI date-range pickers and API request validation.","Convert all timestamps to UTC before comparing."],"tags":["cassandra","query-validation","time-range"],"backgroundTag":"invalid-time-range","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}