Merge pull request #18722 from roidelapluie/roidelapluie/guard-nil-funcall

promql: guard against nil function call in eval
This commit is contained in:
Julien 2026-05-19 11:59:44 +02:00 committed by GitHub
commit e3055ac41e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2063,6 +2063,11 @@ func (ev *evaluator) eval(ctx context.Context, expr parser.Expr) (parser.Value,
return ev.evalInfo(ctx, e.Args)
}
// Functions with nil entries in FunctionCalls should have been handled before reaching this point.
if call == nil {
panic(fmt.Errorf("unexpected nil implementation for function %q", e.Func.Name))
}
// Emit a warning when sort is used for range queries.
if (e.Func.Name == "sort" || e.Func.Name == "sort_desc" || e.Func.Name == "sort_by_label" || e.Func.Name == "sort_by_label_desc") && ev.startTimestamp != ev.endTimestamp {
warnings.Add(annotations.NewSortInRangeQueryWarning(e.PositionRange()))