fix(whatsapp): normalise bare phone numbers to JIDs before bridge send - #41667
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(whatsapp): normalise bare phone numbers to JIDs before bridge send#41667liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
The Baileys bridge expects full WhatsApp JIDs (e.g.
`15551234567@s.whatsapp.net`). When send_message() was called with a
bare phone number like `whatsapp:15551234567`, the Python adapter passed
the raw number to the bridge, causing `jidDecode()` to return null and
the bridge to crash with:
Cannot destructure property 'user' of 'jidDecode(...)'
Add `_ensure_jid_suffix()` — a static method that appends
`@s.whatsapp.net` to any chat_id that doesn't already contain `@`.
Called at the entry point of `send()`, `edit_message()`,
`_send_media_to_bridge()`, and `send_typing()`.
Fixes NousResearch#41660
Contributor
|
Fixed on main via #50379 (salvage of #8639) — bare WhatsApp phone targets are now normalized to @sgaofen's #8639 was the earliest of this cluster, so it was used as the base and credited first; thanks @liuhao1024 for independently catching and fixing the same bug. Closing as duplicate. |
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.
What does this PR do?
Normalises bare phone numbers to full WhatsApp JIDs before posting to the Baileys bridge. Previously,
send_message(target="whatsapp:15551234567")passed the raw number to the bridge, causingjidDecode()to return null and a 500 error.Related Issue
Fixes #41660
Type of Change
Changes Made
gateway/platforms/whatsapp.py: Added_ensure_jid_suffix()static method that appends@s.whatsapp.netto anychat_idwithout an@character. Called at entry point ofsend(),edit_message(),_send_media_to_bridge(), andsend_typing().tests/gateway/test_whatsapp_jid_suffix.py: 10 tests — 7 unit tests for the static method (bare number, already-JID, @lid, @g.us, empty, None, E.164 +prefix) + 3 integration tests verifying the bridge POST payload is normalised.How to Test
Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.exampleif I added/changed config keys — N/ACode Intelligence
_ensure_jid_suffix+send,edit_message,_send_media_to_bridge,send_typingingateway/platforms/whatsapp.py@pass through unchanged@lid,@s.whatsapp.net); this PR handles the complementary case of auto-appending the suffix to bare numbers