Skip to content

fix: sanitize hyphenated session-search FTS queries - #7820

Closed
samwei12 wants to merge 1 commit into
NousResearch:mainfrom
samwei12:fix/session-search-hyphenated-or-query
Closed

fix: sanitize hyphenated session-search FTS queries#7820
samwei12 wants to merge 1 commit into
NousResearch:mainfrom
samwei12:fix/session-search-hyphenated-or-query

Conversation

@samwei12

@samwei12 samwei12 commented Apr 11, 2026

Copy link
Copy Markdown

Summary

Fix a session-search FTS edge case where a broad OR query can fail if one of the search terms is hyphenated.

Linked issue

Closes #7824

Problem

A query such as:

  • 错题本 OR 错题 OR wrong-book OR mistakes

can fail in SQLite FTS5 with:

  • sqlite3.OperationalError: no such column: book

because a bare hyphenated token like wrong-book may be interpreted as a column-filter expression instead of a normal term.

Fix

Keep the change narrow in the FTS sanitization path:

  • collapse duplicated boolean operators that may remain after sanitization
  • quote dotted/hyphenated tokens so FTS5 treats them as phrases during MATCH execution

Why this scope

This PR intentionally stays at the query sanitization layer and adds only regression coverage for the reported failure mode. It does not add tool-layer retry/fallback behavior or unrelated search semantics changes.

Verification

  • pytest -q tests/test_hermes_state.py::TestFTS5Search

- collapse duplicated boolean operators during FTS query sanitization
- quote hyphenated terms like wrong-book so broad OR queries remain executable
- add regression coverage for the reported session search query path
@samwei12 samwei12 changed the title fix: sanitize hyphenated terms in FTS5 OR queries fix: sanitize hyphenated session-search FTS queries Apr 11, 2026
@samwei12 samwei12 closed this Apr 14, 2026
@samwei12
samwei12 deleted the fix/session-search-hyphenated-or-query branch April 14, 2026 15:31
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.

Session search broad FTS query can fail on hyphenated OR terms

1 participant