fix(falkordb): handle empty sanitized query in build_fulltext_query#1415
Open
smcdonnell7 wants to merge 1 commit intogetzep:mainfrom
Open
fix(falkordb): handle empty sanitized query in build_fulltext_query#1415smcdonnell7 wants to merge 1 commit intogetzep:mainfrom
smcdonnell7 wants to merge 1 commit intogetzep:mainfrom
Conversation
When every token of the input query is a RediSearch stopword (or the
input is empty / whitespace-only), the stopword filter on line 417
collapses `sanitized_query` to an empty string. The function then
emits a fulltext query of the form:
(@group_id:"...") ()
RediSearch rejects this with a syntax error, which surfaces as a
500 from any graphiti search whose subject happens to be an
all-stopword phrase. Real-world triggers include entity names like
"will send the", "the one", "it is", or any fact text produced by
the LLM extractor that reduces to stopwords.
Minimal repro (against an existing FalkorDB):
from graphiti_core.driver.falkordb_driver import FalkorDriver
d = FalkorDriver(host='localhost', port=6379)
# Before this patch, the resulting fulltext query ends in " ()"
# and Graphiti.search_() raises a RediSearch syntax error.
q = d.build_fulltext_query('will the it', group_ids=['my_group'])
assert '()' not in q
Fix: when the sanitized query is empty after stopword filtering,
return either the empty string (no group filter) or just the
group filter on its own, so RediSearch receives a valid query.
Member
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
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
FalkorDriver.build_fulltext_querycrashes RediSearch when every token of the input reduces to a stopword.After line 417 filters stopwords,
sanitized_querycan become the empty string. The function then emits:RediSearch rejects this with a syntax error, which surfaces as a 500 from any
Graphiti.search_()call whose subject happens to be an all-stopword phrase. Real-world triggers we hit in production:"will send the","the one","it is".Repro
Against any running FalkorDB instance:
End-to-end,
graphiti.search_(query="will send the", group_ids=["x"])returns an empty result set instead of raising.Fix
When the sanitized query is empty after stopword filtering, return either the empty string (no group filter) or just the group filter on its own, so RediSearch receives a valid query. Keeps the upstream behaviour for every non-empty case identical.
Test plan
"shopify migration") unchanged