What happened
After the parser refactoring in #17977, promtool check config no longer respects --enable-feature flags for PromQL experimental features (e.g. promql-experimental-functions, promql-extended-range-selectors).
Root cause
In cmd/promtool/main.go, the CheckConfig function creates a default parser with no features enabled:
// cmd/promtool/main.go:622
rulesFailed, rulesHaveErrors := checkRules(ruleFiles, lintSettings.rulesLintConfig, parser.NewParser(parser.Options{}))
Before #17977, this code path called parser.ParseExpr() which read global flags that were set earlier in main(). Now that globals are replaced with per-instance options, this call site uses a fresh parser that ignores the user's feature flags stored in promtoolParserOpts.
Expected behavior
promtool check config --enable-feature=promql-experimental-functions myconfig.yml should accept rules using experimental PromQL functions.
Actual behavior
Rules using experimental PromQL functions are rejected with parse errors, even when the corresponding --enable-feature flag is passed.
Fix
Pass promtoolParser (or accept it as a parameter) instead of parser.NewParser(parser.Options{}).
What happened
After the parser refactoring in #17977,
promtool check configno longer respects--enable-featureflags for PromQL experimental features (e.g.promql-experimental-functions,promql-extended-range-selectors).Root cause
In
cmd/promtool/main.go, theCheckConfigfunction creates a default parser with no features enabled:Before #17977, this code path called
parser.ParseExpr()which read global flags that were set earlier inmain(). Now that globals are replaced with per-instance options, this call site uses a fresh parser that ignores the user's feature flags stored inpromtoolParserOpts.Expected behavior
promtool check config --enable-feature=promql-experimental-functions myconfig.ymlshould accept rules using experimental PromQL functions.Actual behavior
Rules using experimental PromQL functions are rejected with parse errors, even when the corresponding
--enable-featureflag is passed.Fix
Pass
promtoolParser(or accept it as a parameter) instead ofparser.NewParser(parser.Options{}).