diff --git a/utils.go b/utils.go index c146981..ee0b211 100644 --- a/utils.go +++ b/utils.go @@ -84,7 +84,7 @@ func IsLikelyInvalid(e Expr) bool { return } idx := GetRollupArgIdx(fe) - if idx < 0 { + if idx < 0 || idx >= len(fe.Args) { return } arg := fe.Args[idx] diff --git a/utils_test.go b/utils_test.go index b60ba3d..6064820 100644 --- a/utils_test.go +++ b/utils_test.go @@ -117,6 +117,9 @@ func TestIsLikelyInvalid(t *testing.T) { f(`rate(rate(foo))`, true) f(`1 + rate(label_set(foo, "bar", "baz"))`, true) f(`rate(sum(foo) offset 5m)`, true) + + // invalid number of args + f(`quantile_over_time(foo)`, false) } func TestIsSupportedFunction(t *testing.T) {