Repository navigation
feat: Add schemas and types for adhoc dashboard filters - #3335
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 901ead5 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 |
🔴 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
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
PR Review
3 finding(s): 🔴 1 critical · 🟠 0 major · 🔵 2 minor 3 posted as inline comment(s) on the changed lines. 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 is a schema/types-only change with strong integration-test coverage; the internal API gains 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Reviewers (8): correctness/adversarial (orchestrator-verified), security, api-contract, testing, maintainability, project-standards, agent-native, previous-comments, learnings. 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 |
E2E Test Results✅ All tests passed • 406 passed • 1 skipped • 1141s
Tests ran across 4 shards in parallel. |
a765173 to
98b109f
Compare
3d5b2c1 to
7d7c818
Compare
7d7c818 to
85dda5a
Compare
| @@ -682,10 +684,14 @@ export function convertToExternalDashboard( | |||
| .map(tile => convertTileToExternalChart(tile, containerById, dashboardId)) | |||
| .filter(t => t !== undefined), | |||
| tags: dashboard.tags || [], | |||
| filters: dashboard.filters?.map(translateFilterToExternalFilter) || [], | |||
| filters: getExternalCompatibleFilters(dashboard.filters).map( | |||
There was a problem hiding this comment.
🔴 critical — External API PUT and MCP saveDashboard silently delete the ADHOC filters and saved values that GET hides
convertToExternalDashboard now leaves ADHOC filters and adhoc saved values out of GET. The update paths still overwrite the whole array, though: routers/external-api/v2/dashboards.ts:3201-3219 sets setPayload.filters = convertExternalFiltersToInternal(filters, …) and setPayload.savedFilterValues = savedFilterValues, and mcp/tools/dashboards/saveDashboard.ts:339,354 does the same. So if a client GETs a dashboard and PUTs it back unchanged (the documented round trip), every ADHOC filter and its saved conditions are wiped. Fix: on update, append the stored ADHOC filters (existingDashboard.filters.filter(isAdhocFilter)) and the stored adhoc values to what the client sent before writing. Add savedFilterValues to the projection at line 3161. Also add an integration test that a GET→PUT round trip keeps them.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| @@ -1978,7 +1979,11 @@ function DBDashboardPage({ | |||
|
|
|||
| const [showFiltersModal, setShowFiltersModal] = useState(false); | |||
|
|
|||
| const filters = dashboard?.filters ?? []; | |||
| // Ad hoc filters aren't rendered or applied yet | |||
| const filters = useMemo( | |||
There was a problem hiding this comment.
🔵 minor — Hiding ADHOC filters from the filters modal skips the variable-name uniqueness check, so the server rejects the save
The filtered filters list goes to DashboardFiltersModal (line 3527). VariableNameInput then checks validateVariableName only against those filters. A user can pick a variable name that a hidden ADHOC filter already uses. The client accepts it, handleSaveFilter writes into the full dashboard.filters, and the PATCH fails with 400 from validateDashboardFilterVariableNames. The user gets no field-level error. Fix: pass the unfiltered dashboard.filters to the modal for the uniqueness check, and still hide ADHOC filters from the list.
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
| sources.find(source => source.id === id)?.name ?? ''; | ||
|
|
||
| if (isAdhocFilter(filter)) { | ||
| filter.sources = filter.sources.map(getSourceName); |
There was a problem hiding this comment.
🔵 minor — Exporting an ADHOC filter with a deleted source produces a template that fails DashboardTemplateSchema
filter.sources.map(getSourceName) turns an unresolved ID into '', but AdhocDashboardFilterSchema.sources is z.array(z.string().min(1)). The exported template fails validation, so the whole dashboard can't be imported, even though import drops ADHOC filters anyway (DBDashboardImportPage.tsx:972). appliesToSourceIds already filters out empty names on the next lines. Fix: filter out empty names from sources the same way and drop the filter if none remain, or leave ADHOC filters out of the export until import supports them. Add a test case for a deleted entry in sources.
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
85dda5a to
901ead5
Compare
Summary
This PR adds the schemas and types for adhoc filters.
Known limitations (will be addressed in subsequent PRs):
Screenshots or video
No behavior change expected other than the internal API now accepts adhoc filters, as demonstrated in the integration tests.
How to test on Vercel preview
References