Skip to content

Commit be2ee44

Browse files
committed
fix(tools): sanitize ExploreCode queries for Cymbal FTS5 safety
py-cymbal's Cymbal CLI interprets hyphens in search queries as SQL FTS5 NOT operators, causing 'no such column' crashes when the model passes hyphenated terms like 'vault-store' or 'home-entry'. Sanitize all symbol queries by replacing hyphens with underscores before passing to Cymbal. This is semantically correct (code symbols use underscores, not hyphens) and prevents the crash regardless of which py-cymbal version is installed. The root cause is in py-cymbal's Go binary (unquoted FTS5 input) — a fix has been reported to the Cymbal team (dwash). This cecli-side workaround provides immediate defense.
1 parent 525f9ab commit be2ee44

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

cecli/tools/explore_code.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ def execute(cls, coder, queries, **kwargs):
120120

121121
try:
122122
if action == "search":
123-
results = c.search(symbol, limit=limit)
123+
# Sanitize symbol: Cymbal's CLI interprets hyphens as SQL operators.
124+
# Replace hyphens with underscores (common in code) and strip special chars.
125+
safe_symbol = symbol.replace("-", "_") if symbol else symbol
126+
results = c.search(safe_symbol, limit=limit)
124127
all_results.append(cls._format_search_results(results, symbol))
125128
elif action == "investigate":
126129
symbol_name = symbol
@@ -131,8 +134,11 @@ def execute(cls, coder, queries, **kwargs):
131134
file_hint = parts[0]
132135
symbol_name = parts[1]
133136

137+
# Sanitize for Cymbal search
138+
safe_name = symbol_name.replace("-", "_") if symbol_name else symbol_name
139+
134140
try:
135-
investigation = c.investigate(symbol_name, file_hint)
141+
investigation = c.investigate(safe_name, file_hint)
136142
all_results.append(
137143
cls._format_investigation_results(investigation, symbol)
138144
)
@@ -151,7 +157,8 @@ def execute(cls, coder, queries, **kwargs):
151157
else:
152158
raise e
153159
elif action == "find_references":
154-
references = c.find_references(symbol, limit=limit)
160+
safe_symbol = symbol.replace("-", "_") if symbol else symbol
161+
references = c.find_references(safe_symbol, limit=limit)
155162
all_results.append(cls._format_reference_results(references, symbol))
156163
else:
157164
all_failed_queries.append(

0 commit comments

Comments
 (0)