Repository navigation
feat: add an "All" option to SQL query dashboard filters - #3861
karl-power wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: d7aee3e 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 |
Duplicate code analysis1 new clone introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
PR Review
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
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. |
| message: tooManyOptionsForAllMessage(filter.name), | ||
| }); | ||
| } else { | ||
| optionsByVariableName.set(name, result.values); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 2c209d8. Configure here.
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 🟡 P2 — recommended
🔵 P3 nitpicks (3)
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:
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 • 490 passed • 1 skipped • 1178s
Tests ran across 4 shards in parallel. |
pulpdrew
left a comment
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Why is it that other filters don't see the all option like tiles do?
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?
Yes, I will add that |
2072641 to
af09246
Compare
| isLoading: false, | ||
| message: `Couldn't load the options for ${filter.name}${error ? `: ${error}` : '.'}`, | ||
| }); | ||
| } else if (!result || result.isLoading) { |
There was a problem hiding this comment.
🟡 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
af09246 to
d7aee3e
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
|
There was a problem hiding this comment.
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).
❌ 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, | ||
| }); |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit d7aee3e. Configure here.
| dateRange={searchedTimeRange} | ||
| variables={variables} | ||
| variables={expandedVariables} | ||
| unavailableVariables={unavailableVariables} |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit d7aee3e. Configure here.
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 I think a warning on circular references, if feasible, is a good alternative! |






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.
Include "All" optioncheckbox, hidden for single-select filters.allowAllon SQL query filters. MCPquery_tileandquery_tileswithall: truerun the filter's query to fill in its options.toSqlQueryFilterValuesand the values query settings moved to common-utils so the app and MCP run the query the same way.Behaviour notes
$variableand$__filteruse every returned option;$__conditionalAllbecomes1=1.1=1, while bare$variablebecomesNULL. Use macros for these dependencies to avoid filtering out every option. Static-list "All" still supplies its full option list;$__conditionalAllremains unconstrained.$variablebecomesNULL, and both macros become1=1.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:
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
allowAllsetting (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. MCPquery_tile/query_tilesmirror the dashboard by runningexpandSqlQueryAllVariableswhen variables useall: 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.