fix(promql): reject non-equality __name__ matchers instead of mislowering (#67) - #73
Merged
Merged
Conversation
…ring (#67) `{__name__=~"node_.*"}` (and `!~` / `!=`) was silently mislowered: `vs_parts` took the first `__name__` matcher's value as the metric name regardless of its operator, then dropped all `__name__` matchers — so a regex name match became an exact literal metric (`Source("node_.*")`) with the match op discarded, selecting the wrong series. A non-equality `__name__` matcher selects *across* metric names, which the single-metric `Source::TimeSeries { metric }` can't represent. Reject it cleanly (like offset/@/without) rather than mislower. Equality `__name__` (`{__name__="up"}`) still names the metric — unchanged. Corpus queries with `__name__=~` now reject instead of mislowering; the totality tests only require no-panic + a lowered floor, so they stay green. Added `name_regex_matcher_is_rejected__GAP` (also guards the equality case). Full workspace suite green; clippy --all-targets clean. Follow-up (needs a wildcard/regex `Source` in the IR): actually support cross-metric name selection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #67 (MEDIUM, from the whole-repo review).
Bug
{__name__=~"node_.*"}(and!~/!=) was silently mislowered.vs_partstook the first__name__matcher's value as the metric name regardless of operator, then dropped all__name__matchers — so a regex name match became an exact literal metricSource("node_.*")with the match op discarded, selecting the wrong series.Fix
A non-equality
__name__matcher selects across metric names, which the single-metricSource::TimeSeries { metric }can't represent. Reject it cleanly (consistent with howoffset/@/withoutare rejected) rather than mislower. Equality__name__({__name__="up"}) still names the metric — unchanged.Verified
{__name__=~"node_.*"}→ rejected (wasSource("node_.*")){__name__!~"x", job="y"}→ rejected{__name__="up"}→Source("up")(unchanged)Corpus queries with
__name__=~now reject instead of mislowering; the totality tests require only no-panic + a lowered floor, so they stay green. Addedname_regex_matcher_is_rejected__GAP. Full suite green (29 binaries), clippy clean.Follow-up: actually supporting cross-metric name selection needs a wildcard/regex
Sourcein the IR — a separate feature.🤖 Generated with Claude Code