fix(ck-engine): parse lexical queries leniently instead of erroring on tantivy syntax#166
Open
ak2k wants to merge 1 commit into
Open
fix(ck-engine): parse lexical queries leniently instead of erroring on tantivy syntax#166ak2k wants to merge 1 commit into
ak2k wants to merge 1 commit into
Conversation
…n tantivy syntax ck is grep-shaped, so lexical (--lex) queries arrive as arbitrary strings — from shell one-liners, scripts, and AI agents — that were never meant to be tantivy query syntax. QueryParser::parse_query rejects the whole search when the input contains anything it can't fully interpret: an unbalanced quote, a stray `field:` colon, a bare AND/OR, a leading wildcard. The terms that could still match are discarded along with the syntax error, and callers are forced to sanitize queries before handing them over. Switch lexical_search to QueryParser::parse_query_lenient: the interpretable terms are kept and the un-parseable fragments are dropped, with the parser's errors logged at debug level rather than propagated. A query that already parses cleanly yields the same query object, so its results and scores are unchanged (covered by an invariance test comparing strict and lenient parses); a query where every fragment errors degrades to normal empty results instead of a hard failure.
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.
ck is grep-shaped, so lexical (
--lex) queries arrive as arbitrary strings — from shell one-liners, scripts, and AI agents — that were never meant to be tantivy query syntax.QueryParser::parse_queryrejects the whole search when the input contains anything it can't fully interpret: an unbalanced quote, a strayfield:colon, a bareAND/OR, a leading wildcard. The terms that could still match are discarded along with the syntax error, and callers are forced to sanitize queries before handing them over.Switch
lexical_searchtoQueryParser::parse_query_lenient: the interpretable terms are kept and the un-parseable fragments are dropped, with the parser's errors logged at debug level rather than propagated. A query that already parses cleanly yields the same query object, so its results and scores are unchanged (covered by an invariance test comparing strict and lenient parses); a query where every fragment errors degrades to normal empty results instead of a hard failure.If you'd rather keep strict parsing as the default, this could sit behind a flag instead — happy to rework it that way.