Skip to content

fix(memory): sanitize FTS5 queries to prevent crashes on hyphenated tokens (#14024)#39663

Open
dusterbloom wants to merge 1 commit into
NousResearch:mainfrom
dusterbloom:fix/holographic-fts5-sanitize
Open

fix(memory): sanitize FTS5 queries to prevent crashes on hyphenated tokens (#14024)#39663
dusterbloom wants to merge 1 commit into
NousResearch:mainfrom
dusterbloom:fix/holographic-fts5-sanitize

Conversation

@dusterbloom

Copy link
Copy Markdown
Contributor

Fixes #14024

Hyphenated tokens (pve-01, lxc-103) in FTS5 MATCH queries caused 'no such column' errors because the unicode61 tokenizer treats hyphens as column-filter operators.

Fix: _sanitize_fts_query() splits on hyphens/punctuation and double-quotes each token. Three-tier fallback: quoted AND → quoted AND retry → OR. Also handles special FTS5 operators, SQL injection, wildcards, and edge cases.

Tests: 27 tests (6 sanitization + 21 parametrized fuzz: SQL injection, null bytes, emoji, FTS5 operators, hyphens, IPs, paths, emails, etc.)

This was originally part of #23221 — split into focused single-fix PRs for easier review.

…okens (NousResearch#14024)

Hyphenated tokens (pve-01, lxc-103) in FTS5 MATCH queries caused
'no such column' errors because the unicode61 tokenizer treats hyphens
as column-filter operators.

Fix: _sanitize_fts_query() splits on hyphens/punctuation and
double-quotes each token. Three-tier fallback: quoted AND -> quoted AND
retry -> OR. Also handles special FTS5 operators, SQL injection,
wildcards, and edge cases like empty queries.

Closes NousResearch#14024
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: fact_store search action fails with "no such column" error on hyphenated queries (FTS5 tokenization)

2 participants