Skip to content

Block a query that has no filters - #85

Merged
Jasper-Maris merged 1 commit into
mainfrom
feature/query-execution-safeguard
Sep 4, 2026
Merged

Jasper-Maris merged 1 commit into
mainfrom
feature/query-execution-safeguard

Conversation

@sharppaul

Copy link
Copy Markdown
Contributor

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.

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.

Copilot AI 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.

🟡 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 runBlockReason guard and apply it in workbench actions and visualiser pages.
  • Add requireQueryFilters setting 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.'
},

@Jasper-Maris Jasper-Maris 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.

looks fine

@Jasper-Maris
Jasper-Maris merged commit 9fe5c1c into main Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants