Block a query that has no filters - #85
Merged
Merged
Conversation
Beacon must not read a whole table. The safeguard stops the run and the download, in the workbench and on the viewer pages. Turn it off with "Require a filter" in the settings.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The viewer-page effects can fail to re-run when the user toggles the safeguard setting off.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a safety guard that blocks query run and download when a query has no filters.
It reduces risk of full-table reads in Beacon Studio, with an override in Settings.
Changes:
- Add
runBlockReasonguard and apply it in workbench actions and visualiser pages. - Add
requireQueryFilterssetting and render boolean settings in the Settings UI. - Add UI warnings for blocked queries on query block cards and parameter block.
File summaries
| File | Description |
|---|---|
| src/routes/visualisations/table-explorer/+page.svelte | Block execution and clear result state when query has no filters. |
| src/routes/visualisations/map-viewer/+page.svelte | Block execution and clear map result when query has no filters. |
| src/routes/visualisations/chart-explorer/+page.svelte | Block execution and clear chart result when query has no filters. |
| src/lib/stores/settings.ts | Add requireQueryFilters setting and a boolean setting definition type. |
| src/lib/query/query-guard.ts | Add shared guard logic to detect and explain filter-less queries. |
| src/lib/components/settings/SettingField.svelte | Render boolean settings with a checkbox control. |
| src/lib/components/query-builder/QueryBuilderSelectorBlock.svelte | Show a warning indicator on blocks that cannot run due to missing filters. |
| src/lib/components/query-builder/QueryBuilderParameterBlock.svelte | Show an inline warning message when the current draft compiles to no filters. |
| src/lib/components/query-builder/QueryActions.ts | Block run and download actions when the guard triggers. |
| src/lib/components/query-builder/QueryActionBar.svelte | Disable run and download UI when the guard triggers. |
| src/lib/components/buttons/VisualiseDataButton.svelte | Add disabled state support for the visualise dropdown trigger. |
| src/lib/components/buttons/DownloadDataButton.svelte | Add disabled state support for the download button. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 6
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+281
to
285
| {#if blockReason} | ||
| <TriangleAlertIcon size="0.75rem" /> | ||
| {/if} | ||
| {status.filters} | ||
| {status.filters == 1 ? 'filter' : 'filters'} |
Comment on lines
+89
to
+92
| // The safeguard stops a query with no filter. Show nothing, and run nothing. | ||
| // The run key stays empty, so a revert of the edit runs the query again. | ||
| const blocked = runBlockReason(untrack(() => compiledQuery)); | ||
| if (blocked) { |
Comment on lines
+117
to
+120
| // The safeguard stops a query with no filter. Show nothing, and run nothing. | ||
| // The run key stays empty, so a revert of the edit runs the query again. | ||
| const blocked = runBlockReason(untrack(() => compiledQuery)); | ||
| if (blocked) { |
Comment on lines
+102
to
+105
| // The safeguard stops a query with no filter. Show nothing, and run nothing. | ||
| // The run key stays empty, so a revert of the edit runs the query again. | ||
| const blocked = runBlockReason(untrack(() => compiledQuery)); | ||
| if (blocked) { |
Comment on lines
+1
to
+8
| /** | ||
| * The filter safeguard of the query workbench. | ||
| * | ||
| * Beacon holds large datasets. A query with no filter reads a whole table, so | ||
| * the workbench blocks it. The user turns the safeguard off on the settings | ||
| * page, with `requireQueryFilters`. | ||
| * | ||
| * The rule reads the compiled query, and not the draft. A draft filter with no |
Comment on lines
+160
to
+162
| description: | ||
| 'Blocks a query with no filters in the workbench. Beacon must not read a whole table.' | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Beacon must not read a whole table. The safeguard stops the run and the download, in the workbench and on the viewer pages. Turn it off with "Require a filter" in the settings.