Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions graphiti_core/driver/falkordb_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ def build_fulltext_query(
filtered_words = [word for word in query_words if word and word.lower() not in STOPWORDS]
sanitized_query = ' | '.join(filtered_words)

if not sanitized_query:
return ''

# If the query is too long return no query
if len(sanitized_query.split(' ')) + len(group_ids or '') >= max_query_length:
return ''
Expand Down
12 changes: 12 additions & 0 deletions tests/utils/search/test_search_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ def test_falkordb_fulltext_query_rejects_invalid_group_ids():
FalkorDriver.build_fulltext_query(driver, 'test', ['bad"group'])


def test_falkordb_fulltext_query_returns_empty_string_for_stopword_only_query():
# Import inside the test so collection still works when FalkorDB extras are unavailable.
from graphiti_core.driver.falkordb_driver import FalkorDriver

driver = MagicMock(spec=FalkorDriver)
driver.sanitize.return_value = 'the and'

result = FalkorDriver.build_fulltext_query(driver, 'the and', ['standups'])

assert result == ''


@pytest.mark.asyncio
async def test_shared_search_rejects_invalid_group_ids():
clients = SimpleNamespace(
Expand Down
Loading