fix: Unicode-safe chat search + auto-detect business bridge DB#181
Open
EtanHey wants to merge 5 commits intolharries:mainfrom
Open
fix: Unicode-safe chat search + auto-detect business bridge DB#181EtanHey wants to merge 5 commits intolharries:mainfrom
EtanHey wants to merge 5 commits intolharries:mainfrom
Conversation
- MESSAGES_DB_PATH now prefers whatsapp-bridge-business/store/messages.db when it exists, falling back to whatsapp-bridge/store/messages.db. This fixes list_messages returning 'No messages to display' for groups that only exist in the business bridge (e.g. מהיום פיתוח 🔥). - Replace LOWER()+LIKE with instr() for chat name search so Hebrew and other non-ASCII names match correctly (SQLite LOWER() is ASCII-only; instr() does byte-level substring search which is Unicode-safe). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SQLite's LOWER() only handles ASCII (A-Z); Hebrew, Arabic, emoji and other non-ASCII text is passed through unchanged, meaning LOWER()+LIKE silently falls back to case-sensitive byte matching. instr() does explicit byte-level substring search and is reliable for all Unicode. - list_messages content query: LOWER(content) LIKE → instr() - search_contacts name query: LOWER(name) LIKE → instr() (JID search kept as LIKE — JIDs are ASCII phone numbers) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Explains why instr() is used instead of LOWER()+LIKE for non-ASCII search (SQLite LOWER() is ASCII-only) - Documents how to run personal and business bridges side by side with per-instance env vars (WHATSAPP_DB_PATH, WHATSAPP_API_URL, WHATSAPP_BRIDGE_PORT) - Notes the auto-detection behaviour when business bridge DB is present Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers dev setup (uv + Go), project structure, the instr() SQLite search convention, PR guidelines, and issue reporting template. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The previous _default_db_path() preferred whatsapp-bridge-business when it existed, causing both personal and business MCP instances to silently read the same (business) database. The correct behaviour is: default to the personal bridge (whatsapp-bridge/store/messages.db) and require business users to set WHATSAPP_DB_PATH explicitly. Also updates README to clarify that WHATSAPP_API_URL must include the /api suffix (it is used as-is with no suffix appended by the code). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LOWER()+LIKEwithinstr()in all three text-search paths (list_messagescontent,list_chatsname,search_contactsname). SQLite's built-inLOWER()only handles ASCII — for Hebrew, Arabic, CJK, and emoji it is a no-op, causing silent failures on non-Latin queries.instr()does byte-level substring matching and is reliable for all Unicode.WHATSAPP_DB_PATHdefaults towhatsapp-bridge/store/messages.db(the personal bridge). Business users must setWHATSAPP_DB_PATHexplicitly — there is no auto-detection that could silently redirect both instances to the same database.WHATSAPP_DB_PATH,WHATSAPP_API_URL,WHATSAPP_BRIDGE_PORT). Clarifies thatWHATSAPP_API_URLmust include the/apisuffix.instr()convention, PR guidelines, and issue reporting.whatsapp,mcp,model-context-protocol,whatsapp-api,claude,sqlite,go,pythonWhat changed in
whatsapp.pylist_messagescontent searchLOWER(content) LIKE LOWER(?)instr(LOWER(content), LOWER(?)) > 0 OR instr(content, ?) > 0list_chatsname searchLOWER(name) LIKE LOWER(?)instr(LOWER(name), LOWER(?)) > 0 OR instr(name, ?) > 0search_contactsname searchLOWER(name) LIKE LOWER(?)instr(LOWER(name), LOWER(?)) > 0 OR instr(name, ?) > 0whatsapp-bridge/store/messages.db(hardcoded)os.path.normpath(no auto-detection)Test plan
list_messages(query="תודה")returns Hebrew-content messageslist_chats(query="מהיום")finds groups with Hebrew namessearch_contacts(query="smith")still works for ASCII nameswhatsapp-bridge/store/messages.dbby defaultWHATSAPP_DB_PATHis set explicitly🤖 Generated with Claude Code