feat: Show warnings for invalid promql variable usage - #2997
Conversation
🦋 Changeset detectedLatest commit: 769ec36 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
E2E Test Results✅ All tests passed • 317 passed • 1 skipped • 1403s
Tests ran across 4 shards in parallel. |
Greptile SummaryAdds language-aware PromQL variable validation and displays its errors and warnings in the PromQL editor.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/variables.ts | Adds PromQL-specific variable and macro validation while limiting existing SQL checks to SQL templates. |
| packages/app/src/components/PromQLEditor/PromQLEditor.tsx | Connects shared variable validation to the PromQL editor's warning, error, and issue-indicator UI. |
| packages/common-utils/src/tests/variables.test.ts | Covers canonical PromQL references, unknown variables, unquoted regex expansions, unsupported macros, and missing variable scope. |
| packages/app/tests/e2e/features/dashboard-filter-variables.spec.ts | Exercises the new PromQL validation messages and verifies that correcting a reference clears the indicator. |
Reviews (4): Last reviewed commit: "feat: Show warnings for invalid promql v..." | Re-trigger Greptile
41bc358 to
33c0a7f
Compare
33c0a7f to
00f6c18
Compare
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Deep Review✅ No critical issues found. This is an additive, well-tested change: it introduces PromQL variable-reference validation where none existed before, and cleanly gates the pre-existing SQL/Lucene checks behind language branches without regressing them. The findings below are recommendations, led by one acknowledged-but-unaddressed gap. 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Reviewers (9): correctness, adversarial, kieran-typescript, testing, maintainability, previous-comments, project-standards, agent-native, learnings-researcher. Testing gaps:
Dropped during re-grading: an adversarial finding that |
00f6c18 to
769ec36
Compare
| const settings = languageSettings(language); | ||
|
|
||
| // A macro-less language leaves a macro exactly as written, so writing one can | ||
| // only ever have been a mistake. |
There was a problem hiding this comment.
nit: would it make more sense to only warn here? Not sure why a user would deliberately do it, but also why not just warn in that case
Summary
This PR improves support for variables in promql by warnings to the promql input when variables are used incorrectly (eg. a non-existent variable is referenced, a macro is used, or the variable is not surrounded by quotes).
Note that this requires enabling the following feature toggles:
(In the UI)
(In the API)
Screenshots or video
How to test
ResourceAttributes['service.instance.id']from the metrics gauge tablehttp_client_duration_milliseconds_count{instance=~"$Instance"}References