#19591: fix(memory): probe FTS5 availability instead of relying on IF NOT EXISTS
size: XS
## Problem
`CREATE VIRTUAL TABLE IF NOT EXISTS ... USING fts5(...)` silently succeeds when the FTS5 table already exists from a prior SQLite build, even when the `fts5` module is **not loaded** in the current runtime. This causes:
- `openclaw status` to report `fts ready` (false positive)
- Actual FTS5 queries to fail with `no such module: fts5`
- Memory sync errors: `[memory] sync failed (watch): Error: no such module: fts5`
### Who is affected?
Any OpenClaw user running **Node 22.x**, which ships SQLite compiled without `SQLITE_ENABLE_FTS5`. The issue is masked when:
1. A previous Node version (or SQLite build) created the FTS5 virtual table
2. The user upgrades/downgrades to a Node version without FTS5 support
3. `IF NOT EXISTS` sees the existing table rows and succeeds without loading the module
### Fix
Add a lightweight probe query after table creation:
```typescript
params.db.prepare(`SELECT count(*) FROM ${params.ftsTable} LIMIT 1`).get();
```
If the fts5 module isn't loaded, this query throws `no such module: fts5`, and the catch block correctly sets `ftsAvailable = false`.
### Testing
- Verified on Node 22.14.0 (SQLite 3.47.2, no FTS5): correctly reports `fts unavailable`
- Verified on Node 24.13.1 (SQLite 3.51.2, has FTS5): correctly reports `fts ready`
- Full test suite: 840 passed, 1 pre-existing failure (unrelated Slack threading test)
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds a probe query after FTS5 virtual table creation to verify the fts5 module is actually loaded. This fixes a false-positive "fts ready" status that occurred when Node 22.x (which ships SQLite without FTS5 support) encountered pre-existing FTS5 table rows from a previous SQLite build - the `IF NOT EXISTS` clause would silently succeed without actually loading the module, causing subsequent FTS5 queries to fail with `no such module: fts5` errors.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is minimal (5 lines), well-documented, targeted at a specific bug, and has been tested across multiple Node versions. The probe query is safe (read-only SELECT with LIMIT 1), uses a constant table name (no SQL injection risk), and the error handling was already in place.
- No files require special attention
<sub>Last reviewed commit: d69d75c</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#8706: fix(memory): fall back to better-sqlite3 when node:sqlite lacks FTS5
by ElmerProject · 2026-02-04
82.8%
#19945: memory: gracefully disable hybrid keyword search when fts5 unavailable
by nico-hoff · 2026-02-18
72.6%
#19920: fix(memory): populate FTS index in FTS-only mode so search returns ...
by forketyfork · 2026-02-18
70.9%
#17686: fix(memory): support non-ASCII characters in FTS query tokenization
by Phineas1500 · 2026-02-16
68.7%
#22732: feat(plugin): add embedding-fts extension
by cintia09 · 2026-02-21
67.2%
#18595: feat: native PostgreSQL + pgvector memory backend
by IrriVisionTechnologies · 2026-02-16
65.7%
#14277: fix(CLI): Use wss for probeUrl, when gateway has tls enabled
by tha80 · 2026-02-11
65.7%
#13168: perf: short-circuit --version to skip process respawn and full modu...
by RamiNoodle733 · 2026-02-10
65.5%
#17237: fix(update): guard post-install imports after npm global update
by tdjackey · 2026-02-15
65.3%
#22716: fix: gateway status probe uses wss:// when TLS enabled; accept self...
by Fratua · 2026-02-21
64.9%