fix(memory): quote FTS5 queries to handle hyphens and special chars#427
fix(memory): quote FTS5 queries to handle hyphens and special chars#427marcusquinn merged 3 commits intomainfrom
Conversation
memory-helper.sh recall failed on hyphenated queries like "pre-edit" because FTS5 interprets hyphens as the NOT operator. Wrapping the query in double quotes makes FTS5 treat it as a literal phrase search. Closes #398
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 7 06:12:06 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in memory-helper.sh where FTS5 queries containing hyphens would fail. The fix correctly wraps the query string in double quotes to ensure it's treated as a literal phrase by FTS5, which is the correct approach. The change is well-explained and effectively resolves the described issue. I have one minor suggestion to improve code readability in the shell script. The change in TODO.md is just a task status update.
| local escaped_query="${query//"'"/"''"}" | ||
| escaped_query="${escaped_query//\"/\"\"}" | ||
| # Escape embedded double quotes for FTS5 (double them), then wrap in quotes | ||
| escaped_query="\"${escaped_query//\"/\"\"}\"" |
There was a problem hiding this comment.
For better readability and to avoid re-assigning to escaped_query, you could use an intermediate variable with a more descriptive name. This makes the purpose of each escaping step clearer and the code easier to follow.
| local escaped_query="${query//"'"/"''"}" | |
| escaped_query="${escaped_query//\"/\"\"}" | |
| # Escape embedded double quotes for FTS5 (double them), then wrap in quotes | |
| escaped_query="\"${escaped_query//\"/\"\"}\"" | |
| local query_sql_escaped="${query//'/'/''}" | |
| # Escape embedded double quotes for FTS5 (double them), then wrap in quotes | |
| local escaped_query="\"${query_sql_escaped//\"/\"\"}\"" |
|
…elpers (t135.3) (#433) * chore: mark t139 complete in TODO.md (#427) * chore: mark t135.14 complete in TODO.md (#426) * fix: add SQLite WAL mode + busy_timeout to supervisor, memory, mail helpers (t135.3) Add db() wrapper function to all three helpers that sets busy_timeout=5000ms on every SQLite connection via '.timeout 5000' dot-command. This prevents 'database is locked' errors during concurrent access by parallel agents. Changes per helper: - supervisor-helper.sh: Add db() wrapper, replace 106 sqlite3 calls, add WAL migration in ensure_db() for pre-existing databases - memory-helper.sh: Add db() wrapper, replace 63 sqlite3 calls, add WAL PRAGMA to init_db() and WAL migration in ensure_db() - mail-helper.sh: Add db() wrapper, replace 36 sqlite3 calls, add WAL migration in ensure_db() for pre-existing databases WAL mode is persistent (set once per DB), but busy_timeout is per-connection and must be set each time. The db() wrapper ensures every sqlite3 invocation gets the timeout. Tested: 20/20 concurrent writes succeed with fix vs 9/20 without. * chore: sync version to 2.105.3 across all files
…432) * chore: mark t139 complete in TODO.md (#427) * chore: mark t135.14 complete in TODO.md (#426) * fix: add ShellCheck enforcement to CI code-quality workflow (t135.6.3) - Add ShellCheck lint step to framework-validation job - Enforces error-severity violations that fail the build - Iterates all git-tracked .sh files with gcc output format - Mark t135.6 subtasks complete (t135.6.1/t135.6.2 done in PR #423)



Summary
memory-helper.sh recallcrashing withRuntime error near line 1: no such column: editwhen queries contain hyphens (e.g.,pre-edit)-as the NOT operator; wrapping queries in double quotes makes them literal phrase searchesRoot Cause
SQLite FTS5 has special syntax characters:
-(NOT),*(prefix),OR,AND, etc. The previous code escaped quotes but didn't protect against operator interpretation. A query likepre-editwas parsed aspre NOT edit, and sinceeditisn't a column name, FTS5 threw an error.Fix
Wrap the escaped query in FTS5 double quotes (
"pre-edit") which tells FTS5 to treat the entire string as a literal phrase. Embedded double quotes are already escaped by doubling them (""), which is the FTS5 convention.Testing
Verified manually:
recall "pre-edit"- no longer crashes (was:no such column: edit)recall "pre-edit-check"- handles multiple hyphensrecall "memory"- normal queries still workrecall 'test "quoted" value'- embedded double quotes workrecall "it's a test"- single quotes workCloses #398