Skip to content

fix(store): sanitize local search FTS queries#301

Merged
upsetbit merged 1 commit into
masterfrom
codex/fix-search-fts-errors
Jun 27, 2026
Merged

fix(store): sanitize local search FTS queries#301
upsetbit merged 1 commit into
masterfrom
codex/fix-search-fts-errors

Conversation

@upsetbit

Copy link
Copy Markdown
Contributor

Summary

Fixes #294.

This PR hardens local FTS search query handling so malformed or punctuation-heavy user queries no longer surface raw SQLite/FTS5 errors.

What changed

  • Quote literal FTS5 terms before passing them to MATCH.
  • Preserve supported operators only when they appear in a valid operator position.
  • Treat punctuation such as hyphens and ordinary parentheses as literal search text unless it is part of supported NEAR (...) syntax.
  • Wrap remaining FTS parser failures as invalid search query ... instead of leaking SQL logic error / fts5: internals.
  • Add regression tests for hyphenated identifiers, dangling operators, punctuation, prefix search, OR, and wrapped invalid NEAR syntax.

Validation

  • go test ./internal/store -run Search -count=1
  • go test ./internal/store/... -race
  • go test ./internal/cli/... -race
  • go build -o ./bin/prosa ./cmd/prosa
  • Manual repro checks for (, foo(bar), audit OR, NOT audit, and invalid NEAR (audit profile, ) against a synthetic local store.

@upsetbit upsetbit added bug Something isn't working area:cli prosa CLI area:store SQLite + Postgres + migrations + FTS5 scope:cli prosa CLI commands, flags, rendering, setup, and scheduled sync scope:store SQLite, Postgres, migrations, FTS, and raw-object metadata severity:medium Latent bug, inconsistent contract, brittle pattern priority:P2 Lower-priority cleanup, coverage, polish, or follow-up source:audit Created from an audit report or validation pass labels Jun 27, 2026
@upsetbit upsetbit merged commit 14ecab4 into master Jun 27, 2026
5 checks passed
@upsetbit upsetbit deleted the codex/fix-search-fts-errors branch June 27, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cli prosa CLI area:store SQLite + Postgres + migrations + FTS5 bug Something isn't working priority:P2 Lower-priority cleanup, coverage, polish, or follow-up scope:cli prosa CLI commands, flags, rendering, setup, and scheduled sync scope:store SQLite, Postgres, migrations, FTS, and raw-object metadata severity:medium Latent bug, inconsistent contract, brittle pattern source:audit Created from an audit report or validation pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search exposes raw SQLite FTS errors for invalid user queries

1 participant