Skip to content

promtool check config ignores --enable-feature flags for PromQL experimental features #18092

Description

@aknuds1

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{}).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions