[BUG] FalkorDriver.build_fulltext_query fails on hyphens in group_id (RediSearch syntax error)
Summary
FalkorDriver.build_fulltext_query in graphiti-core 0.29 emits RediSearch queries that fail at parse time when group_id contains hyphens. The driver's comment claims to handle hyphens via quoting; the implementation only wraps in "…" without escaping.
This is related to but distinct from #1425 (hyphens in episode title) and #757 (general FalkorDB query errors). The root cause is the same RediSearch tokenizer behavior; this issue isolates it to the group_id field which is typically a UUID — so the bug fires 100% of the time for any user passing UUID-shaped group_ids.
Reproduce
import asyncio, json
from datetime import datetime, timezone
from graphiti_core import Graphiti
from graphiti_core.driver.falkordb_driver import FalkorDriver
from graphiti_core.nodes import EpisodeType
async def main():
driver = FalkorDriver(host="localhost", port=6379, database="repro")
g = Graphiti(graph_driver=driver)
await g.add_episode(
name="repro",
episode_body=json.dumps([{"subject": "a", "predicate": "X", "object": "b"}]),
source=EpisodeType.json,
source_description="repro",
reference_time=datetime.now(timezone.utc),
group_id="00000000-0000-0000-0000-000000000001", # any hyphenated value
)
asyncio.run(main())Expected
add_episode completes successfully.
Actual
ERROR [graphiti_core.driver.falkordb_driver] Error executing FalkorDB query:
RediSearch: Syntax error at offset 17 near 00000000
ResponseError: RediSearch: Syntax error at offset 17 near 00000000The failing query (logged from a local patch) is:
CALL db.idx.fulltext.queryRelationships('RELATES_TO', $query)
YIELD relationship AS rel, score
MATCH (n:Entity)-[e:RELATES_TO {uuid: rel.uuid}]->(m:Entity)
WHERE e.uuid in $edge_uuids AND e.group_id IN $group_ids
...With params:
{'query': '(@group_id:"00000000-0000-0000-0000-000000000001") (Entity | has | …)', ...}Offset 17 lands at the first hyphen inside "00000000-0000-…".
Root cause
graphiti_core/driver/falkordb_driver.py, around line 413:
# Escape group_ids with quotes to prevent RediSearch syntax errors
# with reserved words like "main" or special characters like hyphens
escaped_group_ids = [f'"{gid}"' for gid in group_ids]The comment is aspirational — wrapping in "…" doesn't escape hyphens for RediSearch's TEXT-field parser. Hyphens inside quoted phrases are still tokenized as separators at parse time and the parser raises a syntax error.
The fulltext index defined at graph_queries.py:103 indexes group_id as a TEXT field via db.idx.fulltext.createNodeIndex. TEXT indexes tokenize hyphens as separators on STORE too, so the stored representation of "foo-bar" is [foo, bar].
Workaround (in our adapter layer)
We're shipping a private compat shim that overrides build_fulltext_query to scrub hyphens + underscores to spaces in group_id values before quoting. Multi-token phrase still matches the stored value because the index tokenizes the same way. Verified locally — full add_episode round-trip with hyphenated group_ids works after the patch.
Happy to send a PR if the maintainers would prefer either:
- The scrub-to-space approach (lightest touch; matches index tokenization), or
- Proper RediSearch backslash escaping (
\-) inside the quoted phrase.
Environment
- graphiti-core: 0.29.0
- Python: 3.13
- FalkorDB: latest (Docker)
- LLM/Embedder: OpenAI (defaults)
Source: getzep/graphiti