fix(hermes-state): quote colon-delimited fts5 literals - #19952
Closed
Que0x wants to merge 1 commit into
Closed
Conversation
Collaborator
1 similar comment
Collaborator
Contributor
Author
|
Closing already fixed. |
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.
Summary
Fixes an FTS5 search bug in
SessionDB.search_messages()where colon-delimited literals and Windows-style paths were misparsed as FTS5 column filters instead of searched as plain text.Queries like
path:config.yamlandC:\Users\demo\projectcould triggerno such columninside SQLite FTS5.search_messages()caught thatOperationalErrorand returned[], so valid searches silently looked like misses.Problem
Hermes recently hardened FTS5 query sanitization for quotes, hyphens, dots, underscores, and boolean operators, but
:remained untreated.That left a real edge case:
path:config.yamlwas sanitized intopath:"config.yaml", which FTS5 interpreted as a column filter on a non-existentpathcolumn.C:\Users\demowas interpreted as a column filter onC.sqlite3.OperationalErrorwas swallowed bysearch_messages(), so users saw empty results instead of matches.This is especially user-visible on Windows and in any workflow that searches config-style tokens, paths, or log fragments containing
:.Fix
Updated
_sanitize_fts5_query()inhermes_state.pyto quote literal-like tokens containing punctuation that FTS5 would otherwise tokenize or interpret as syntax, including:._-:/\The implementation uses a single token-based pass so we preserve existing behavior for:
and avoid double-quoting mixed forms like
my-app.config.ts.Tests
Added regression coverage in
tests/test_hermes_state.pyfor:path:config.yamlC:\Users\demo\projectValidation
Ran: