Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 5035e69 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 |
7fda981 to
1e5d44a
Compare
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
E2E Test Results✅ All tests passed • 490 passed • 1 skipped • 1321s
Tests ran across 4 shards in parallel. |
1e5d44a to
5035e69
Compare
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Additional context: touches background tasks or the delivery pipeline lightly (9 lines, under the 30-line bar for Tier 4) Review process: Full human review — logic, architecture, edge cases. Stats
|
| * Build the variable context a dashboard tile runs with: its value variables, | ||
| * plus the data source and connection variables its text can reference. | ||
| */ | ||
| export function resolveDashboardVariables( |
There was a problem hiding this comment.
🟡 P2 — MCP runs a text reference to an unselected or invalid source/connection variable as empty SQL instead of returning an error
getReferenceChartVariables quietly drops a selection that is missing or not offered, so SELECT count() FROM $src reaches ClickHouse as SELECT count() FROM and the agent only sees a syntax error. resolveTileVariableReferences (same file) returns an error naming the variable for the same state, and the new MCP prompt text says the tile 'waits for a selection'. Fix: in queryTile/queryTiles, collect the reference-variable names the tile's text uses (getVariableReferences) and return a mcpUserError that names any of them without a valid selection, the way the sourceId path already does.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| selectedId(filter.id), | ||
| ]), | ||
| ); | ||
| variables.push( |
There was a problem hiding this comment.
🟡 P2 — Tiles that reference a selected variable run with an empty expansion while sources or connections are still loading
buildReferenceChartVariables reports hasSelection: false whenever sources/connections is undefined (the first render in DBDashboardPage, since useSources()/useConnections() are async) or the selected connection ID is unknown. unsatisfiedRequiredFilters only looks at selectionByFilterId, which still holds the URL selection, so the tile is not blocked and FROM $src runs as FROM and errors. Fix: treat a selection that hasn't resolved yet (targets not loaded, or an ID that isn't found) as pending and block the tile, or skip building reference variables until the targets are loaded.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| database != null && table != null ? [database, table] : undefined, | ||
| ), | ||
| ], | ||
| ['table', identifierField(table != null ? [table] : undefined)], |
There was a problem hiding this comment.
🟡 P2 — A metric-only data source variable still declares $m/${m.table}, which can never render
The '' and table fields are always declared, so completions offered while nothing is selected suggest $m and ${m.table}. Validation run with empty variables (MCP getTileVariableWarnings, alerts) doesn't flag them either, because resolveReferenceSegments skips the check when unselected. They only fail once a source is picked. Also, isMetricSource is guessed from non-empty metricTables rather than the source kind, so a metric source with no tables configured renders `default`. ``. Fix: omit the bare and table fields when `allowedSourceKinds` is exactly `[Metric]`, and pass `kind` into `ReferenceVariableSource` to decide whether a source is a metric source.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| } | ||
|
|
||
| const unguarded = resolved.filter( | ||
| const quotedReferences = referenceRefs.filter( |
There was a problem hiding this comment.
🟡 P2 — A quoted identifier reference like '${src.table}' gives a silently wrong string and no warning
In SQL, ${src.table} defaults to sqlidentifier. So WHERE name = '${src.table}' (a common pattern against system.tables) renders '`otel_logs`' and matches nothing. The new quoted-reference check only covers effectiveFormat === 'sqlstring'. Fix: report sqlidentifier references with inStringLiteral too, and suggest ${src.table:csv} or :sqlstring.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
7 finding(s): 🔴 0 P0/P1 · 🟡 6 P2 · 🔵 1 P3 4 posted as inline comment(s) on the changed lines. 2 listed below. 1 P3 folded at the bottom. Findings outside the changed lines
🔵 1 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5035e69. Configure here.
| ...declaration, | ||
| values: [], | ||
| })); | ||
| const variables = getEmptyDashboardVariables(details.dashboard.filters); |
There was a problem hiding this comment.
Alerts ignore source text references
Medium Severity
Alert evaluation always builds dashboard variables with empty source and connection selections via getEmptyDashboardVariables. SQL that references $src or ${src.table} therefore expands to an empty identifier, so a tile such as SELECT count() FROM $src runs as FROM and fails, even though the alert already has a resolved details.source.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 5035e69. Configure here.
| sources, | ||
| connections, | ||
| }), | ||
| ); |
There was a problem hiding this comment.
Unloaded sources empty selected references
Medium Severity
buildReferenceChartVariables only fills table and name fields when a sources (or connections) list is provided. While useSources() is still loading, sources is undefined, so a selected $src is treated as unselected and expands to nothing. Required-filter checks still see the ID, so a raw SQL tile can run FROM instead of waiting.
Reviewed by Cursor Bugbot for commit 5035e69. Configure here.
| /** How a reference to a field is written: `$src` for the bare form, else `${src.field}`. */ | ||
| function formatFieldReference(name: string, key: string): string { | ||
| return key === '' ? `$${name}` : `\${${name}.${key}}`; | ||
| } |
There was a problem hiding this comment.
Braced source completions omit default field
Low Severity
formatFieldReference emits only $src for the default field, not ${src}. Value-variable completions already add the braced form because typing ${ cannot fuzzy-match $src. Source variables therefore hide the database.table completion at the exact moment the user is writing ${src.table} or ${src}.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 5035e69. Configure here.
Deep Review✅ No critical issues found. Security verified the new escaping path end-to-end: 🟡 P2 -- recommended
🔵 P3 nitpicks (5)
Reviewers (11): correctness, security, adversarial, testing, maintainability, project-standards, typescript, api-contract, agent-native, learnings-researcher, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |


Summary
This PR introduces the ability to reference data source and connection variables within text (SQL, markdown) contexts, via
$source, ${source}, ${source.name}, ${source.id}, ${source.table}, ${source.database}, ${source.table.<metric data type>}, ${Connection.name}, ${Connection.id}.The
sqlidentifierformat is introduced, to backtick-quote and sql-escape identifiers, and is the default format when referencing a source's table or database.Screenshots or video
Screen.Recording.2026-12-01.at.6.49.48.PM.mov
How to test on Vercel preview
Create a data source variable and connection variable. Reference them in SQL or markdown text inputs. Test auto-complete, warnings/errors for invalid references, and empty states.
References
Note
Medium Risk
Changes how dashboard SQL and templates are expanded (including identifiers sent to ClickHouse), across UI, API, and shared utils; well-tested but affects the core query path.
Overview
Dashboard DATA_SOURCE and CONNECTION filters can now be referenced inside SQL, markdown, and related text—not only as
sourceId/connectionIdon tiles. Braced forms like$logs,${logs.table},${cluster.name}, and metric-specific${m.table.gauge}expand from the selected source/connection metadata; unselected or invalid selections render empty. A newsqlidentifierformat backtick-quotes identifiers (default for table/database fields in SQL).common-utils extends variable scanning/substitution with field paths,
ChartVariable.reference, validation for reference fields, and helpers (buildReferenceChartVariables,getEmptyDashboardVariables,getFiltersDeclaringVariables). App wires reference variables throughuseDashboardFilters, SQL autocomplete, and markdown validation; tiles block on required source/connection variables when text references them. API/MCP resolves the same reference context when running dashboard tiles and documents the syntax in MCP prompts.Reviewed by Cursor Bugbot for commit 5035e69. Bugbot is set up for automated code reviews on this repo. Configure here.