feat: Add static value list filters to schemas and APIs - #3017
Conversation
🦋 Changeset detectedLatest commit: 7fc1722 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.
|
Greptile SummaryThe PR extends dashboard filter schemas and API contracts with a variable-only
Confidence Score: 4/5The PR is not yet safe to merge because static-list URL selections can still inject values outside the authored option set into dashboard tile variables. Variable-keyed filter values are accepted unchanged by Files Needing Attention: packages/common-utils/src/dashboardFilterValues.ts; packages/app/src/hooks/useDashboardFilters.tsx
|
| Filename | Overview |
|---|---|
| packages/common-utils/src/types.ts | Defines the discriminated dashboard-filter union and the variable-only static-list schema. |
| packages/common-utils/src/dashboardFilterValues.ts | Adds variable-keyed static-list selection resolution while the previously reported option-domain issue remains outstanding. |
| packages/common-utils/src/dashboardValidation.ts | Adds shared validation for static-list option uniqueness and filter-type field constraints. |
| packages/api/src/utils/zod.ts | Exposes strict external API schemas for query-expression and static-list filter variants. |
| packages/api/src/routers/external-api/v2/utils/dashboards.ts | Integrates static-list validation and avoids source lookup for sourceless filter variants. |
| packages/app/src/DBDashboardImportPage.tsx | Preserves static filters during dashboard import while remapping sources only for queried filters. |
| packages/app/src/DashboardFilters.tsx | Restricts ClickHouse-backed value queries to query-expression filters as part of the intentionally deferred static-filter UI work. |
| packages/app/src/components/DashboardFiltersModal/index.tsx | Keeps the existing editor limited to query-expression filters pending the explicitly deferred static-list editing UI. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Author[API or dashboard import] --> Validate[Discriminated filter validation]
Validate --> Persist[(Dashboard configuration)]
Persist --> Load[Dashboard filters]
Load --> Query[QUERY_EXPRESSION values from ClickHouse]
Load --> Static[STATIC_LIST authored options]
Query --> Selection[Dashboard selection state]
Static --> Selection
Selection --> Variables[Tile variables]
Selection --> Broadcast[Query-expression broadcast filters]
Reviews (5): Last reviewed commit: "fix: Fix tests and lint" | Re-trigger Greptile
E2E Test Results✅ All tests passed • 323 passed • 1 skipped • 1405s
Tests ran across 4 shards in parallel. |
92804e3 to
6b98b88
Compare
6b98b88 to
ef89c78
Compare
ef89c78 to
72ab9d2
Compare
72ab9d2 to
7fc1722
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:
Additional context: touches background tasks or the delivery pipeline lightly (8 lines, under the 30-line bar for Tier 4) Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Deep Review✅ No critical issues found. The 🟡 P2 -- recommended
🔵 P3 nitpicks (8)
Reviewers (9): correctness, adversarial, api-contract, kieran-typescript, testing, maintainability, security, previous-comments, project-standards. Testing gaps:
|
Summary
This PR updates schemas, types, and API contracts to support Static List type dashboard filters, which show a static list of author-provided options instead of values queried from ClickHouse.
These new filters have no associated
expressionand therefore support only variable mode (they cannot be converted to a SQL condition for broadcast mode).The updated DashboardFilter type / schema is a discriminated union on type, where STATIC_LIST is a new
type.The internal and external API have been updated to accept, transform, and validate the new type. Dashboard import has been updated to support the new type. The UI has been updated only to avoid type errors, and will not display the new filter type.
Followup work includes:
Screenshots or video
Create via API
Get via API
Included in export
Not shown in import (no source to remap)
MCP can still fetch a dashboard's filters
How to test locally
Importable Dashboard
{ "version": "0.1.0", "name": "Test Static Filters", "tiles": [ { "id": "bd61ewiiu2fs52pkhwe9u", "x": 0, "y": 10, "w": 8, "h": 10, "config": { "name": "", "source": "Logs", "displayType": "line", "granularity": "auto", "alignDateRangeToGranularity": true, "select": [ { "aggFn": "count", "aggCondition": "", "aggConditionLanguage": "lucene", "valueExpression": "" } ], "where": "", "whereLanguage": "lucene" } }, { "id": "hmlgrh1me14q19ewy9pci", "x": 8, "y": 10, "w": 8, "h": 10, "config": { "name": "", "source": "Demo Logs", "displayType": "line", "granularity": "auto", "alignDateRangeToGranularity": true, "select": [ { "aggFn": "count", "aggCondition": "", "aggConditionLanguage": "lucene", "valueExpression": "" } ], "where": "", "whereLanguage": "lucene" } }, { "id": "7jwjomsz0pdmigm0kyorgp", "x": 0, "y": 0, "w": 9, "h": 10, "config": { "displayType": "table", "granularity": "auto", "alignDateRangeToGranularity": true, "configType": "sql", "sqlTemplate": "SELECT $env", "connection": "Local ClickHouse", "source": "Logs", "name": "Selected $env values" } } ], "filters": [ { "id": "6a91d80f1e4e008c07f1c411", "name": "ServiceName (Traces)", "type": "QUERY_EXPRESSION", "expression": "ServiceName", "source": "JSON Traces" }, { "id": "6a91d7081e4e008c07f1c265", "name": "Environment", "variableName": "env", "type": "STATIC_LIST", "options": [ "dev", "staging", "prod" ], "isBroadcastEnabled": false, "isVariableEnabled": true }, { "id": "6a91d7af1e4e008c07f1c35d", "name": "Status (Traces)", "type": "QUERY_EXPRESSION", "expression": "StatusCode", "source": "JSON Traces" }, { "id": "7ca33140-cdfc-4434-bd29-62782c7aa3b0", "name": "Severity", "variableName": "Severity", "type": "QUERY_EXPRESSION", "expression": "SeverityText", "source": "Demo Logs", "appliesToSourceIds": [ "Demo Logs", "Demo Traces" ], "isBroadcastEnabled": true, "isVariableEnabled": true } ], "containers": [] }References