Repository navigation
feat: support data source and connection variables in the external API and MCP - #3652
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ef79c91 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
E2E Test Results✅ All tests passed • 464 passed • 1 skipped • 1121s
Tests ran across 4 shards in parallel. |
Duplicate code analysis2 new clones introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
e3a8941 to
99b9fdd
Compare
99b9fdd to
b3c9d46
Compare
b3c9d46 to
2d42ba3
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
PR Review
5 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 5 minor 3 posted as inline comment(s) on the changed lines. 2 listed below. Findings outside the changed lines2 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This PR extends the external v2 API and MCP dashboard tools with The substantive prior review comment (a PromQL tile silently running against a variable-selected log source) is confirmed addressed: 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers: correctness, security, adversarial, api-contract, kieran-typescript, testing, maintainability, reliability, project-standards, previous-comments, agent-native, learnings-researcher. Coverage note: At synthesis time, structured results had returned from the previous-comments and learnings reviewers; the remaining findings reflect the orchestrator's own diff analysis across the correctness, security, reliability, api-contract, maintainability, and typescript lenses. Independent verification found the OpenAPI schemas ( Testing gaps: Test coverage for the new paths is substantial ( 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 |
2d42ba3 to
8d348eb
Compare
55a0535 to
e0ba99b
Compare
| .describe( | ||
| 'Filter type discriminator for a variable whose value is a source.', | ||
| ), | ||
| allowedSourceKinds: z |
There was a problem hiding this comment.
🔵 minor — Non-PromQL MCP filter schema lets a DATA_SOURCE variable offer promql sources
mcpDataSourceFilterSchema uses z.nativeEnum(SourceKind), and it is in both mcpDashboardFilterSchema and mcpPromqlDashboardFilterSchema. With PromQL off, an agent can still save allowedSourceKinds: ["promql"]. Every other filter shuts PromQL out of the non-PromQL schema (ADHOC sourceType is z.literal('sql')). isPromqlFilter in routers/external-api/v2/utils/dashboards.ts also doesn't hide these variables from hidePromql reads. Fix: use a non-PromQL variant of the schema (drop SourceKind.Promql) in the non-PromQL union.
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
| * PROMETHEUS_LABEL: '#/components/schemas/PrometheusLabelFilterInput' | ||
| * SQL_QUERY: '#/components/schemas/SqlQueryFilterInput' | ||
| * ADHOC: '#/components/schemas/AdhocFilterInput' | ||
| * DATA_SOURCE: '#/components/schemas/DataSourceFilterInput' |
There was a problem hiding this comment.
🔵 minor — OpenAPI DATA_SOURCE/CONNECTION schemas omit fields that GET returns
translateFilterToExternalFilter returns these filters with minSelections: 1, maxSelections: 1, isBroadcastEnabled: false and isVariableEnabled: true. The strict external Zod shapes accept those fields, but DataSourceFilterInput and ConnectionFilterInput (reused by the Filter response schema) don't document them. PrometheusLabelFilterInput documents its fixed fields. Fix: add the four fields as single-value enums with defaults, so generated clients match what GET returns and PUT accepts.
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
Summary
PR 2/5 adding data source and data connection type variables. This PR adds external API and MCP support.
Source and connection variables allow for dashboards variable inputs that define a source or connection queried by a tile or other filters. Selected values are stored in source or connection id slots in the saved chart config, in the
$varNameformat, then converted to source or connection IDs at runtime when there is a selection.Variables are substituted prior to rendering the dashboard, at the top level, so that components and configs down the stack can just use source and connection IDs like they have been.
Direct
$sourcereferences are not yet allowed in SQL tiles - the source is selected at the chart level and $__sourceTable can be used to reference it. Connection variables are mostly only useful for (a) raw sql tiles and (b) source variables that can be scoped to a single connection, dynamically.How to test on Vercel preview
The E2E feature can be tested on PR 5: #3656
References