{"record":{"id":"82bd16a643c24adb","repo":"jaegertracing/jaeger","slug":"invalid-parameters","errorCode":null,"errorMessage":"invalid parameters","messagePattern":"invalid parameters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/metricstore/elasticsearch/reader.go","lineNumber":237,"sourceCode":"\tspan := r.queryLogger.TraceQuery(ctx, p.metricName)\n\tdefer span.End()\n\n\tsearchResult, err := r.queryBuilder.Execute(ctx, p.boolQuery, p.aggQuery, timeRange)\n\tif err != nil {\n\t\terr = fmt.Errorf(\"failed executing metrics query: %w\", err)\n\t\tr.queryLogger.LogErrorToSpan(span, err)\n\t\treturn nil, err\n\t}\n\n\tr.queryLogger.LogAndTraceResult(span, searchResult)\n\n\t// Return raw search result\n\treturn searchResult, nil\n}\n\nfunc calculateTimeRange(params *metricstore.BaseQueryParameters) (TimeRange, error) {\n\tif params == nil || params.EndTime == nil || params.Lookback == nil {\n\t\treturn TimeRange{}, errors.New(\"invalid parameters\")\n\t}\n\tendTime := *params.EndTime\n\tstartTime := endTime.Add(-*params.Lookback)\n\textendedStartTime := startTime.Add(-10 * time.Minute)\n\n\treturn TimeRange{\n\t\tstartTimeMillis:         startTime.UnixMilli(),\n\t\tendTimeMillis:           endTime.UnixMilli(),\n\t\textendedStartTimeMillis: extendedStartTime.UnixMilli(),\n\t}, nil\n}\n","sourceCodeStart":219,"sourceCodeEnd":249,"githubUrl":"https://github.com/jaegertracing/jaeger/blob/806f4447841ecdb60519f408b004a599d515f437/internal/storage/metricstore/elasticsearch/reader.go#L219-L249","documentation":"calculateTimeRange in the Elasticsearch metrics reader validates that a *metricstore.BaseQueryParameters pointer carries a non-nil EndTime and a non-nil Lookback before deriving the query window (start = EndTime - Lookback, extended by 10 minutes). If params itself is nil, or either required field is a nil pointer, it returns this error instead of dereferencing nil. It is raised before any Elasticsearch request is sent, so the metric query never executes.","triggerScenarios":"Calling MetricsReader.GetLatencies, GetCallRates, or GetErrorRates with a *metricstore.BaseQueryOptions whose BaseQueryParameters is nil, has EndTime == nil, or has Lookback == nil. This typically happens when the caller constructs query options manually instead of through the query-plugin HTTP/gRPC layer, which normally defaults these fields.","commonSituations":"Embedding jaeger metrics reader in a custom service and building BaseQueryOptions by hand; forgetting to populate Lookback while only setting EndTime; a config/flags path that skips the default lookback (e.g. --query.frequency / lookback flags not applied); passing zero-value structs where pointers stay nil.","solutions":["Set both EndTime and Lookback (non-nil pointers) on params.BaseQueryParameters before calling GetLatencies/GetCallRates/GetErrorRates.","If you only have an end time, assign a sensible Lookback such as time.Duration pointed value (e.g. lookback := metricstore.LookbackFor(endTime) or a fixed 1h).","Use the standard jaeger query HTTP handler paths, which populate defaults, instead of calling the metrics reader directly with partial options.","Validate the options in your own code before invoking the reader so the failure is surfaced with context."],"exampleFix":"// before\nparams := &metricstore.BaseQueryOptions{}\npoints, err := metricsReader.GetCallRates(ctx, params)\n// after\nend := time.Now()\nlookback := time.Hour\nparams := &metricstore.BaseQueryOptions{\n\tBaseQueryParameters: &metricstore.BaseQueryParameters{\n\t\tEndTime:  &end,\n\t\tLookback: &lookback,\n\t},\n}\npoints, err := metricsReader.GetCallRates(ctx, params)","handlingStrategy":"validation","validationCode":"func validMetricsParams(p *metricstore.BaseQueryParameters) bool {\n\treturn p != nil && p.EndTime != nil && p.Lookback != nil\n}\n// call site:\nif !validMetricsParams(opts.BaseQueryParameters) {\n\treturn fmt.Errorf(\"metrics query requires EndTime and Lookback\")\n}","typeGuard":"func hasTimeRange(p *metricstore.BaseQueryParameters) bool {\n\treturn p != nil && p.EndTime != nil && p.Lookback != nil\n}","tryCatchPattern":null,"preventionTips":["Always build metric query options through a constructor that defaults EndTime and Lookback.","Never construct BaseQueryParameters as a zero-value struct; set both pointer fields explicitly.","Add a unit test asserting GetLatencies/GetCallRates/GetErrorRates receive fully populated parameters.","Centralize lookback policy (e.g. 1h default) in one helper so it cannot be omitted per call site."],"tags":["go","elasticsearch","metrics","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"806f4447841ecdb60519f408b004a599d515f437","analyzedAt":"2026-09-01T02:39:22.140Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}