Skip to content

feat: add an "All" option to SQL query dashboard filters - #3861

Open
karl-power wants to merge 2 commits into
claude/sql-filter-all-static-listfrom
claude/sql-filter-all-sql-query
Open

karl-power wants to merge 2 commits into
claude/sql-filter-all-static-listfrom
claude/sql-filter-all-sql-query

Conversation

@karl-power

@karl-power karl-power commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

SQL query dashboard filters can now offer "All", which selects every option the filter's query returns. Stacked on #3847, which added "All" for static list filters.

  • The SQL query filter settings get the Include "All" option checkbox, hidden for single-select filters.
  • The dashboard page loads the options of SQL query filters with "All" selected and fills them in for tiles. It runs the same query as the filter's dropdown, so the result is shared, not fetched twice.
  • Tiles that reference the variable wait for the options, and show an error when they can't be loaded or there are more than 1,000. The tile editor's preview does the same.
  • The SQL query filter form explains, under its SQL editor, how "All" on other filters behaves in its options query.
  • The external API and MCP accept allowAll on SQL query filters. MCP query_tile and query_tiles with all: true run the filter's query to fill in its options.
  • The 1,000-option cap is documented in the checkbox, OpenAPI and MCP descriptions.
  • toSqlQueryFilterValues and the values query settings moved to common-utils so the app and MCP run the query the same way.

Behaviour notes

  • In tiles, "All" makes $variable and $__filter use every returned option; $__conditionalAll becomes 1=1.
  • In dependent filter queries, including filter-editor previews, a SQL query filter's "All" means no constraint: both macros become 1=1, while bare $variable becomes NULL. Use macros for these dependencies to avoid filtering out every option. Static-list "All" still supplies its full option list; $__conditionalAll remains unconstrained.
  • Tiles and tile-editor previews that reference the variable wait for its options. Failed queries or more than 1,000 options show an error instead of running; unrelated tiles remain usable.
  • Empty results behave like nothing selected: bare $variable becomes NULL, and both macros become 1=1.
  • The options query stops after 30 seconds and returns partial results. The filter, tiles that use its "All", and MCP tile runs then show a warning that the list may be incomplete. Tiles still run.
  • MCP expands every SQL query filter passed all: true; one failed or over-cap filter fails the whole call, even for unrelated tiles.

How to test

On this branch, import this dashboard to ClickStack and follow the instructions:
{"version":"0.1.0","name":"TEST: SQL query All — tiles and editor","tags":["testing","sql-filters","all-option"],"tiles":[{"id":"6b0d3d27e6df08cb05ff4ef4","x":0,"y":0,"w":24,"h":7,"config":{"name":"Start here","source":"","displayType":"markdown","markdown":"**Keep Region set to All; change Scenario to test.** This demo uses 1,002 synthetic rows (region IDs 0–1001), so no telemetry data is needed.\n\n- **Ready:** 3 options → bare / filter / conditionalAll = **3 / 3 / 1,002**.\n- **At limit:** 1,000 options → **1,000 / 1,000 / 1,002**.\n- **Over limit:** 1,001 options → dependent tiles and editor previews show the cap error.\n- **Query error:** deliberate options-query failure → dependent tiles and editor previews show the error.\n- **Loading:** about 10 seconds of loading, then **5 / 5 / 1,002**. Change **Run** to repeat with an uncached query.\n- **Empty:** zero options → **0 / 1,002 / 1,002**, the documented empty-selection behavior.\n\nThe **Unrelated control** must stay at **1,002**, even while other tiles are blocked.","select":[],"where":""}},{"id":"6b0d3d27e6df08cb05ff4ef5","x":0,"y":7,"w":6,"h":4,"config":{"displayType":"number","numberFormat":{"output":"number","mantissa":0,"thousandSeparated":true},"configType":"sql","sqlTemplate":"SELECT count() AS \"Matching rows\"\nFROM (SELECT number AS region_id, toString(number) AS region, $__fromTime_ms AS ts FROM numbers(1002))\nWHERE $__timeFilter_ms(ts)\n  AND region IN ($region)\nLIMIT 1","connection":"Local ClickHouse","name":"Bare variable — selected IDs"}},{"id":"6b0d3d27e6df08cb05ff4ef6","x":6,"y":7,"w":6,"h":4,"config":{"displayType":"number","numberFormat":{"output":"number","mantissa":0,"thousandSeparated":true},"configType":"sql","sqlTemplate":"SELECT count() AS \"Matching rows\"\nFROM (SELECT number AS region_id, toString(number) AS region, $__fromTime_ms AS ts FROM numbers(1002))\nWHERE $__timeFilter_ms(ts)\n  AND $__filter(region, $region)\nLIMIT 1","connection":"Local ClickHouse","name":"Filter macro — selected IDs"}},{"id":"6b0d3d27e6df08cb05ff4ef7","x":12,"y":7,"w":6,"h":4,"config":{"displayType":"number","numberFormat":{"output":"number","mantissa":0,"thousandSeparated":true},"configType":"sql","sqlTemplate":"SELECT count() AS \"Matching rows\"\nFROM (SELECT number AS region_id, toString(number) AS region, $__fromTime_ms AS ts FROM numbers(1002))\nWHERE $__timeFilter_ms(ts)\n  AND $__conditionalAll(region IN ($region), $region)\nLIMIT 1","connection":"Local ClickHouse","name":"conditionalAll — unconstrained on All"}},{"id":"6b0d3d27e6df08cb05ff4ef8","x":18,"y":7,"w":6,"h":4,"config":{"displayType":"number","numberFormat":{"output":"number","mantissa":0,"thousandSeparated":true},"configType":"sql","sqlTemplate":"SELECT count() AS \"Matching rows\"\nFROM (SELECT number AS region_id, toString(number) AS region, $__fromTime_ms AS ts FROM numbers(1002))\nWHERE $__timeFilter_ms(ts)\nLIMIT 1","connection":"Local ClickHouse","name":"Unrelated control — always 1,002"}},{"id":"6b0d3d27e6df08cb05ff4ef9","x":0,"y":11,"w":12,"h":7,"config":{"displayType":"table","configType":"sql","sqlTemplate":"SELECT\n  region_id AS \"Region ID\",\n  if(region IN ($region), 'kept', 'dropped') AS \"Bare variable\",\n  if($__filter(region, $region), 'kept', 'dropped') AS \"Filter macro\",\n  if($__conditionalAll(region IN ($region), $region), 'kept', 'dropped') AS \"conditionalAll\"\nFROM (SELECT number AS region_id, toString(number) AS region, $__fromTime_ms AS ts FROM numbers(1002))\nWHERE $__timeFilter_ms(ts)\nORDER BY region_id\nLIMIT 12","connection":"Local ClickHouse","name":"Which sample rows each expression keeps"}},{"id":"6b0d3d27e6df08cb05ff4efa","x":12,"y":11,"w":12,"h":7,"config":{"name":"Markdown expansion — also guarded in the editor","source":"","displayType":"markdown","markdown":"**Selected region values:** [$region]\n\nThis tile should show the same loading or error message as the query tiles when its options are unavailable. Its editor preview should do the same.\n\nAt the 1,000-option boundary this list is long; use the number tiles to check the count.","select":[],"where":""}},{"id":"6b0d3d27e6df08cb05ff4efb","x":0,"y":18,"w":24,"h":7,"config":{"name":"Editor checks and recovery","source":"","displayType":"markdown","markdown":"**Editor check**\n1. Choose **Over limit** or **Query error**, leaving **Region = All**.\n2. Open **Edit** on **Filter macro — selected IDs**. With **Apply filters** on, the preview must show the same unavailable message as the tile.\n3. Turn **Apply filters** off → **1,002**. Turn it back on → blocked again.\n4. Close the editor and switch **Scenario** back to **Ready** → **3**.\n\n**Loading:** select **Loading**, then immediately open the editor. If cached, change **Run** first or while Loading is selected. There should be no temporary unfiltered number.\n\n**Selection semantics:** with Ready selected, clear Region → **0 / 1,002 / 1,002**; pick one ID → **1 / 1 / 1**; restore All → **3 / 3 / 1,002**.\n\nAll queries are synthetic and read-only. The time picker does not change the sample IDs. For MCP validation, pass Scenario and Region explicitly; MCP ignores these saved defaults and intentionally fails the whole call for an unavailable All filter.","select":[],"where":""}}],"filters":[{"id":"6b0d3d27e6df08cb05ff4efc","name":"Scenario","variableName":"scenario","maxSelections":1,"type":"STATIC_LIST","options":["Ready","At limit","Over limit","Query error","Loading","Empty"],"isBroadcastEnabled":false,"isVariableEnabled":true},{"id":"6b0d3d27e6df08cb05ff4efd","name":"Region","variableName":"region","type":"SQL_QUERY","connection":"Local ClickHouse","sqlTemplate":"WITH ifNull(arrayElement([$scenario], 1), 'Ready') AS scenario\nSELECT toString(number) AS region\nFROM numbers(multiIf(scenario = 'At limit', 1000, scenario = 'Over limit', 1001, scenario = 'Empty', 0, scenario = 'Loading', 5, 3))\nWHERE throwIf(scenario = 'Query error', 'Intentional SQL All options failure') = 0\n  AND sleepEachRow(if(scenario = 'Loading', 2., 0.)) = 0\n  AND ifNull(arrayElement([$run], 1), '1') != ''\nLIMIT 1001\nSETTINGS max_block_size = 1, max_threads = 1","allowAll":true,"isBroadcastEnabled":false,"isVariableEnabled":true},{"id":"6b0d3d27e6df08cb05ff4efe","name":"Run","variableName":"run","maxSelections":1,"type":"STATIC_LIST","options":["1","2","3"],"isBroadcastEnabled":false,"isVariableEnabled":true}],"containers":[],"savedFilterValues":[{"type":"variable","name":"scenario","values":["Ready"]},{"type":"variable","name":"region","values":[],"all":true},{"type":"variable","name":"run","values":["1"]}]}

References


Note

Medium Risk
Changes how dashboard tiles and MCP resolve SQL variables when "All" is selected, including live ClickHouse option queries, 1,000-option limits, and macro expansion semantics that affect query correctness across dependent filters.

Overview
This PR extends "All" dashboard filter support from static lists to SQL query filters via an allowAll setting (external API, OpenAPI, MCP schemas). When All is selected, tiles need the filter’s options query result expanded into variable values (cap 1,000); until then they block with loading/error placeholders, and warn if the options query hits the 30 s cutoff.

The app adds useExpandedSqlQueryVariables, wires expanded variables into tiles and the tile editor (including markdown preview), surfaces cut-off cautions on SQL filter dropdowns, and exposes the Include "All" option checkbox on SQL query filter settings with SQL-specific help text.

common-utils centralizes values-query settings (SQL_QUERY_FILTER_VALUES_SETTINGS), result normalization, cut-off detection, and expansion error messages. MCP query_tile / query_tiles mirror the dashboard by running expandSqlQueryAllVariables when variables use all: true, failing on load errors or >1,000 options and attaching per-tile warnings when lists may be incomplete.

Dependent filter/options queries treat a sibling SQL filter’s All as no constraint ($__filter / $__conditionalAll → 1=1, bare $variable → NULL); static-list All still supplies full option values.

Reviewed by Cursor Bugbot for commit d7aee3e. Bugbot is set up for automated code reviews on this repo. Configure here.

@karl-power
karl-power requested a review from a team as a code owner November 30, 2026 10:25
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Dec 2, 2026 10:35am UTC
hyperdx-storybook Ready Ready Preview Dec 2, 2026 10:35am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7aee3e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/api Minor
@hyperdx/app Minor
@hyperdx/common-utils Minor
@hyperdx/otel-collector Minor

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

@karl-power
karl-power added this pull request to stack #3848 November 30, 2026 10:26
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/app/src/hooks/usePromqlLabelFilterValues.tsx:131-139 ↔ packages/app/src/hooks/useSqlQueryFilterValues.tsx:243-252 — 9 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 109 in total (1.09%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 P0/P1 in code this PR adds or changes: fix before asking for review.
  • 🟡 P2 in code this PR changes: your call. Fix if small, otherwise reply.
  • 🔵 P3 is collapsed at the bottom: nobody needs to act on it before merge.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    priority. Reply with one sentence; if it is P0, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

2 finding(s): 🔴 0 P0/P1 · 🟡 2 P2 · 🔵 0 P3

None could be anchored to changed lines; they are listed below.

Findings outside the changed lines

  • 🟡 P2 packages/app/src/hooks/useExpandedSqlQueryVariables.ts:2043 — Tiles expand "All" with the previous query's options while the options query re-runs → useSqlQueryFilterValues uses placeholderData: keepPreviousData (useSqlQueryFilterValues.tsx:210), and its data map sets isLoading: result.isLoading, which stays false while placeholder data is shown. So when the date range or another filter's selection changes the options SQL, this check (!result || result.isLoading) passes. Tiles then run with the old option list. For an options query that takes up to 30 s, tiles can show wrong data for that long, and every tile runs twice. SqlQueryFilterPreview (SqlQueryFilterEditForm.tsx:375) already works around the same placeholder data. Fix: add isPlaceholderData (or isFetching && isPlaceholderData) to each entry in useSqlQueryFilterValues's data map, and treat it as loading here. The hook's tests mock useSqlQueryFilterValues entirely, so they can't catch this; add a test that re-renders with a changed key and real react-query placeholder behaviour.
  • 🟡 P2 packages/api/src/mcp/tools/dashboards/sqlQueryAllValues.ts:493 — MCP runs each "All" filter's options query one after another → The for … await loadOptions(...) loop runs one query at a time, and each can take up to the 30 s max_execution_time. A query_tiles call with three slow "All" filters waits about 90 s before any tile runs. The queries don't depend on each other, because each sees the unexpanded variables. Run them with Promise.all and check the results afterwards.

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.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

message: tooManyOptionsForAllMessage(filter.name),
});
} else {
optionsByVariableName.set(name, result.values);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiles run with stale All options

Medium Severity

Tiles can keep running against a previous options list after the values query key changes. useExpandedSqlQueryVariables only waits while isLoading is true, but useSqlQueryFilterValues sets placeholderData: keepPreviousData, so a refetch reports isLoading false and still returns the old values. Those stale options are expanded as All and tiles query immediately instead of showing the loading placeholder.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2c209d8. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On TanStack Query 5.90, useQueries creates a new observer when a query's key changes, so keepPreviousData never supplies placeholder data here: isLoading is true and tiles wait for the new options. Pinned by a test in #3862 (b3b2426).

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. No injection, auth-bypass, data-loss, or guaranteed-crash defect survives verification — expanded option values route through the existing escapeSqlString quoting, the new MCP options query stays team-scoped, and allowAll + single-select is rejected on both external-REST and MCP save paths via validateDashboardFilterFieldGating. The items below are reliability/design and coverage concerns worth addressing before or shortly after merge.

🟡 P2 — recommended

  • packages/api/src/mcp/tools/dashboards/queryTiles.ts:239 — expandSqlQueryAllVariables expands every allowAll filter on the dashboard and returns a single {error} on the first failed or over-cap options query, so query_tile/query_tiles fails outright for tiles that never reference the offending variable, defeating the batch's per-tile error isolation.
    • Fix: Scope expansion and its error to the variables each requested tile references, and mark only those tiles errored instead of failing the whole call.
    • reliability, adversarial
  • packages/app/src/hooks/useExpandedSqlQueryVariables.ts:131 — the tile loading gate checks only result.isLoading while useSqlQueryFilterValues sets placeholderData: keepPreviousData; correctness rests on undocumented TanStack v5.90 useQueries observer behavior, is unpinned by any test here, and diverges from SqlQueryFilterPreview which guards with isLoading || isFetching.
    • Fix: Surface isPlaceholderData from useSqlQueryFilterValues and treat a placeholder result as still-loading, or add a test pinning that a query-key change keeps the variable loading.
    • previous-comments, julik-frontend-races
  • packages/api/src/mcp/tools/dashboards/sqlQueryAllValues.ts:97 — options queries run sequentially, each capped at 30 s, before the per-tile batch deadline is set, so N all filters can serialize to roughly N×30 s and exhaust the MCP tool timeout before any tile runs.
    • Fix: Bound the expansion phase under the batch deadline and run the options queries with bounded concurrency.
  • packages/api/src/mcp/tools/dashboards/queryTiles.ts:238 — the plural query_tiles path gained All-expansion, the error short-circuit, and per-tile cut-off warning wiring with no integration coverage (queryTiles.int.test.ts has no allowAll case; only the singular tool is covered).
    • Fix: Add a query_tiles integration test asserting the load/over-cap error path and a cut-off warning riding alongside a per-tile result.
🔵 P3 nitpicks (3)
  • packages/common-utils/src/variableSelection.ts:48 — when an "All" options query returns zero rows, expandAllSelections keeps values: [], so a tile using bare $var renders IN (NULL) (matches nothing) while $__filter/$__conditionalAll render 1=1 (matches everything); the behavior is documented but surprising and unpinned.
    • Fix: Add a test pinning the intended empty-All semantics across bare $var and the macros, and confirm the bare-variable rendering is intended.
  • packages/app/src/DBDashboardPage.tsx:1025 — the tile-level cut-off warning icon and the unavailable-variables loading placeholder have no component or e2e assertion (e2e covers only the over-1000 error text).
    • Fix: Add an e2e/component check for the cut-off warning icon and the loading placeholder.
  • packages/app/src/hooks/useExpandedSqlQueryVariables.ts:111 — the All-expansion orchestration (collect → load → cap → warn → expand) is reimplemented in both the app hook and sqlQueryAllValues.ts, sharing only leaf helpers, so the two decision paths can drift.
    • Fix: Extract a shared pure reducer over per-filter results that both call sites feed.
    • maintainability, kieran-typescript

Reviewers (12 of 13 returned): correctness (dispatched; did not return before synthesis — its lens is partly covered by adversarial, reliability, and security), testing, maintainability, project-standards, security, api-contract, reliability, kieran-typescript, julik-frontend-races, adversarial, previous-comments, agent-native, learnings-researcher.

Testing gaps:

  • query_tiles (plural) has no allowAll/All integration coverage; its error short-circuit and cut-off warning are only indirectly tested.
  • No test pins the stale-options gate on a query-key change (that isLoading stays true and tiles wait rather than running against previous values).
  • The empty-options All expansion is untested, so the IN (NULL) vs 1=1 divergence is unverified.
  • The exactly-1,000-option accept boundary is untested; only the 1,001-reject side is covered.
  • No test asserts that an unrelated erroring or over-cap All filter leaves other MCP tiles running.

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

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 490 passed • 1 skipped • 1178s

Status Count
✅ Passed 490
❌ Failed 0
⚠️ Flaky 16
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation LGTM, but I am wondering about the rationale behind the dependent filters behavior, asked below.

Also, re The options query stops after 30 seconds and returns partial results, so "All" can silently select an incomplete list. - could we show a warning in this case so it isn't silent?

connectionId ClickHouse connection the query runs on (from clickstack_list_sources), or a CONNECTION filter's "$variableName".
sourceId Optional log, trace, session, or metric source on that connection, or a DATA_SOURCE filter's "$variableName". Needed for $__sourceTable and $__filters; $__filters expands to the dashboard's broadcast filter selections for that source.
sqlTemplate SELECT whose FIRST column becomes the dropdown values, cast to string with nulls and duplicates dropped, in row order (add ORDER BY). May use the time macros and other filters' variables, plus $__sourceTable and $__filters when sourceId is set.
allowAll Set true to add an "All" choice that selects every option the query returns, up to 1,000; tiles show an error above that, so add a LIMIT if the query can return more. Multi-select filters only. Other filters' sqlTemplates see this filter's "All" as no constraint: $__filter and $__conditionalAll expand to 1=1 there and a bare $variableName to NULL, so reference it through the macros.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it that other filters don't see the all option like tiles do?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also leads to this misleading error message

Screenshot 2026-11-30 at 1 49 38 PM

@karl-power

Copy link
Copy Markdown
Contributor Author

Implementation LGTM, but I am wondering about the rationale behind the dependent filters behavior, asked below.

Originally the idea came from aligning with source filters, but it also prevents infinite waiting for co-dependent filters, where neither can load because each references the other. Also, if one filter returns more than 1,000 options, expanding its "All" in a dependent filter's query would hit the 1000 option limit.

However, I'm now thinking maybe we should just align this with Grafana like the rest of the feature (so expand "All" in dependent filters, and show a warning for circular dependencies). What do you think?

Also, re The options query stops after 30 seconds and returns partial results, so "All" can silently select an incomplete list. - could we show a warning in this case so it isn't silent?

Yes, I will add that

isLoading: false,
message: `Couldn't load the options for ${filter.name}${error ? `: ${error}` : '.'}`,
});
} else if (!result || result.isLoading) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 P2 — Stale placeholder options are treated as loaded, so tiles run "All" with the previous query's option list

useSqlQueryFilterValues uses placeholderData: keepPreviousData, so when the date range or another filter's selection changes the options SQL, result.isLoading stays false and result.values and result.isCutOff still hold the old query's results. SqlQueryFilterEditForm.tsx:375 already calls this out ("isLoading alone would show them as this query's results"). Here the !result || result.isLoading branch misses that state. Every dependent tile and editor preview runs straight away with the outdated IN (...) list, shows wrong numbers, then runs again when the real options arrive. Fix: have useSqlQueryFilterValues report isPlaceholderData (or isFetching && isPlaceholderData) for each filter and mark the variable as loading while it is set. Add a hook test for that state; the current tests mock the values hook and never cover it.

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

@karl-power
karl-power force-pushed the claude/sql-filter-all-sql-query branch from af09246 to d7aee3e Compare December 2, 2026 10:31
@github-actions github-actions Bot added the review/tier-4 Critical — deep review + domain expert sign-off label Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

🔴 Tier 4 — Critical

Touches 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:

  • Critical-path files (1) — tenancy, public API, or shipped database config:
    • packages/api/src/routers/external-api/v2/dashboards.ts
  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)

Review process: Deep review from a domain expert. Synchronous walkthrough may be required.
SLA: Schedule synchronous review within 2 business days.

Stats
  • Production files changed: 23
  • Production lines changed: 796 (+ 816 in test files, excluded from tier calculation)
  • Critical-path lines changed: 10
  • Branch: claude/sql-filter-all-sql-query
  • Author: karl-power

To override this classification, remove the review/tier-4 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@karl-power

Copy link
Copy Markdown
Contributor Author

Warnings for slow/cut-off filter values:

Screenshot 2026-12-02 at 11 14 51 Screenshot 2026-12-02 at 11 08 28 Screenshot 2026-12-02 at 11 08 50

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ 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 d7aee3e. Configure here.

: undefined,
}
: undefined,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MCP All skips broadcast filters

Medium Severity

MCP All expansion runs the filter options query without applying $__filters. loadOptions calls renderSqlQueryFilterValuesQuery with no filtersSQL, so broadcast selections for the filter's source become 1=1. The dashboard path expands those filters before listing options, so query_tile / query_tiles with all: true can return a different option set, wrongly hit the 1,000 cap, or include rows the dashboard would exclude.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d7aee3e. Configure here.

dateRange={searchedTimeRange}
variables={variables}
variables={expandedVariables}
unavailableVariables={unavailableVariables}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor omits incomplete All warning

Low Severity

The tile editor never receives variableWarnings, so a 30s cut-off All list is used in the preview with no warning. Dashboard tiles and MCP attach cutOffOptionsForAllMessage when the options query stops early; EditTileModal only gets unavailableVariables, so the same incomplete expansion is silent while editing.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d7aee3e. Configure here.

@pulpdrew

pulpdrew commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Originally the idea came from aligning with source filters, but it also prevents infinite waiting for co-dependent filters, where neither can load because each references the other.

Ah I see, good points.

A long term goal, IMO, is to get rid of source filters, and this All option is a step towards feature parity. For the source filters use-case, I think it's important that All can be rendered as the full list of available values, both in a tile and in a dependent filter. It's also good to be consistent between dependent filters and tiles if possible. IMO it's also desirable to allow the user to choose whether the expansion is 1=1 for cases where that is faster or where the number of options is >1000, which I think your $__filter and $__conditionalAll allow the user to choose.

I think a warning on circular references, if feasible, is a good alternative!

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — d7aee3ed Deployed Dec 2, 2026 by vercel[bot]
Preview – hyperdx-storybook — d7aee3ed Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-4 Critical — deep review + domain expert sign-off

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants