{"record":{"id":"d547445e50983027","repo":"jaegertracing/jaeger","slug":"start-time-minimum-is-above-maximum-d54744","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/v2/elasticsearch/tracestore/core/reader.go","lineNumber":56,"sourceCode":"\toperationNameField     = \"operationName\"\n\tparentSpanIDField      = \"parentSpanID\"\n\tobjectTagsField        = \"tag\"\n\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}","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/v2/elasticsearch/tracestore/core/reader.go#L38-L74","documentation":"ErrStartTimeMinGreaterThanMax is a sentinel error returned by validateQuery in the Elasticsearch trace reader when a trace query's start-time range is inverted: the minimum (earlier-bound) time is later than the maximum (later-bound) time. The library rejects such queries up front rather than issuing a range filter that can never match. It is also asserted in TestTraceQueryParameterValidation to document this validation contract.","triggerScenarios":"Calling reader.FindTraceIDs/FindTraces with a TraceQueryParameters whose StartTimeMin is after StartTimeMax (e.g. StartTimeMin=now, StartTimeMax=now-1h). validateQuery compares the two times before building the Elasticsearch query and returns this error.","commonSituations":"Swapping the order of start/end arguments when constructing query parameters; UI code computing min/max from user input where the user picks an inverted date range; timezone conversion mistakes that shift the 'min' past the 'max'.","solutions":["Swap the values so StartTimeMin is the earlier time and StartTimeMax is the later time.","Validate the time range in your caller before invoking the reader (return a 400 to users with an inverted range).","If you intended a duration-style query, use the Duration fields instead of the start/end time fields."],"exampleFix":"// before\nparams := v2api.TraceQueryParameters{StartTimeMin: tMax, StartTimeMax: tMin}\n// after\nif tMin.After(tMax) { tMin, tMax = tMax, tMin }\nparams := v2api.TraceQueryParameters{StartTimeMin: tMin, StartTimeMax: tMax}","handlingStrategy":"validation","validationCode":"func validateTimeRange(p *api.TraceQueryParameters) error {\n    if p == nil { return errors.New(\"nil params\") }\n    if p.StartTimeMin.After(p.StartTimeMax) {\n        return errors.New(\"StartTimeMin must be <= StartTimeMax\")\n    }\n    return nil\n}\nif err := validateTimeRange(&params); err != nil { /* handle before calling reader */ }","typeGuard":null,"tryCatchPattern":"traces, err := reader.FindTraces(ctx, query)\nif errors.Is(err, core.ErrStartTimeMinGreaterThanMax) {\n    return http.StatusBadRequest // inverted time range\n}","preventionTips":["Always normalize the pair: if min.After(max), swap before building query params.","Derive min/max from a single lookback duration rather than two independent user inputs.","Add a unit test asserting your query builder never emits inverted ranges."],"tags":["elasticsearch","query-validation","time-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"}