You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ClickHouseVectorStore: top_k SQL-interpolation + no reconnect persistence — hidden by MagicMock #844
ClickHouseVectorStore (src/synapsekit/retrieval/clickhouse_vector.py), previously only MagicMock-tested, had two bugs found via a real clickhouse-server testcontainer (epic #829). (It correctly offloads via run_in_executor — async is fine.)
Bugs
top_k interpolated into the SQL LIMIT — f"... LIMIT {top_k}" with no validation. A non-int top_k is injected verbatim (ClickHouse rejects multi-statements, but the store shouldn't rely on that). Now cast to a positive int, so a payload like "5; DROP TABLE ..." raises ValueError before hitting the DB.
No reconnect persistence — search() returned [] when not self._table_created, so a reconnected instance never found existing rows. Now _search_sync checks EXISTS TABLE and returns [] only when the table genuinely doesn't exist.
Test
Real clickhouse-server testcontainer: true nearest-neighbour ranking (L2Distance), metadata filter, top_k, reconnect persistence, top_k-injection rejection, empty/negative, async contract. Replaces the MagicMock test; runs in the CI integration job.
Activity
fix(retrieval): harden ClickHouseVectorStore against injection and fi…