Skip to content

fix: refuse to run invalid search queries instead of matching everything - #87

Merged
ytkimirti merged 9 commits into
DX-3147-query-stringsfrom
DX-3147-query-invalid
Nov 24, 2026
Merged

ytkimirti merged 9 commits into
DX-3147-query-stringsfrom
DX-3147-query-invalid

Conversation

@ytkimirti

Copy link
Copy Markdown
Collaborator

Bug: When the search query can't be parsed (e.g. a missing closing brace while typing), the browser silently searches with {} and lists every document, and Export exports the whole index. Both call sites used parseJSObjectLiteral(query) ?? {}.
Fix: Parse the query with a new parseSearchQuery that returns undefined for invalid input, and refuse to search or export in that case with an "Invalid query syntax" error.

Why each change

  • lib/utils.ts: parseSearchQuery keeps an empty query as {} (match everything, the existing behavior), but returns undefined for invalid syntax and for non-object values like [1], which are not valid filters either.
  • lib/utils.ts: INVALID_QUERY_MESSAGE is shared so the search and export show the same error.
  • components/databrowser/hooks/use-keys.tsx: throws instead of searching, so the error goes through the existing query error display in the query builder panel.
  • components/databrowser/components/search/export-results-button.tsx: the filter is computed once per render; the estimate is skipped and the dialog shows the error, and the export button is disabled, so an export can never run against {}.
  • lib/utils.test.ts: locks in that an empty query matches everything and invalid or non-object queries are undefined.

Repro: Pick a search index, type { title: "x" (no closing brace) in the Code Editor: every document is listed; open Export and it estimates and exports the whole index.

Part of DX-3147

@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
react-redis-browser Ready Ready Preview Nov 17, 2026 4:13pm UTC

Request Review

@linear-code

linear-code Bot commented Oct 15, 2026

Copy link
Copy Markdown

DX-3147

@ytkimirti
ytkimirti marked this pull request as ready for review October 22, 2026 11:33
@ytkimirti
ytkimirti added this pull request to stack #118 October 28, 2026 07:55
@ytkimirti
ytkimirti merged commit 9184b76 into master Nov 24, 2026
5 checks passed
@ytkimirti
ytkimirti deleted the DX-3147-query-invalid branch November 24, 2026 10:13

This branch was successfully deployed

1 active deployment
Preview — c79ff2c2 Deployed Nov 17, 2026 by vercel[bot]
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.

2 participants