fix(whatsapp): normalize bare phone targets to JIDs (salvage #8639) - #50379
Merged
Conversation
Baileys' jidDecode crashes ("Cannot destructure property 'user' of
jidDecode(...) as it is undefined") when handed a bare phone number, so
sending a WhatsApp message to +50766715226 / 50766715226 returned HTTP
500 and never delivered (#8637).
Add to_whatsapp_jid() to gateway/whatsapp_identity.py — the outbound
inverse of normalize_whatsapp_identifier: it builds the JID a send must
use (bare phone -> <digits>@s.whatsapp.net) and passes through already
qualified JIDs (@g.us, @lid, status@broadcast, @newsletter) unchanged.
Wire it at every outbound bridge call site in the WhatsApp adapter
(send, edit, media, typing, get_chat_info, and the standalone cron /
send_message sender).
Co-authored-by: Hermes Agent <noreply@nousresearch.com>
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/gateway/test_whatsapp_to_jid.py:10: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
✅ Fixed issues: none
Unchanged: 5951 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced Jun 21, 2026
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
WhatsApp sends to a bare phone number now reach the bridge as a valid JID instead of crashing it. Salvages #8639 (@sgaofen, earliest of the cluster) onto current main.
Baileys'
jidDecodecrashes —Cannot destructure property 'user' of jidDecode(...) as it is undefined— when handed a bare phone number, sosend_message(target="whatsapp:+50766715226")and--deliver whatsapp:...cron jobs returned HTTP 500 and never delivered (#8637).Changes
gateway/whatsapp_identity.py: addto_whatsapp_jid()— the outbound inverse ofnormalize_whatsapp_identifier. Bare phone (+50766715226/50766715226) →50766715226@s.whatsapp.net; already-qualified JIDs (@g.us,@lid,status@broadcast,@newsletter) pass through unchanged. Single source of truth, beside the existing identity helpers — no duplicate normalizer.plugins/platforms/whatsapp/adapter.py: apply it at all 6 outbound bridge call sites (send,edit,_send_media_to_bridge,send_typing,get_chat_info, and the standalone cron/send_messagesender).to_whatsapp_jid.Salvage notes
The adapter was migrated to a bundled plugin and the identity helpers were extracted since #8639 was opened, so the original diff no longer applies. Reauthored onto current main:
whatsapp_identity.py(next tonormalize_whatsapp_identifier) rather than a new private helper in the adapter.:device@domainhandling —replace(":", "@", 1)produced the broken60123456789@47@s.whatsapp.net; now collapses correctly to60123456789@s.whatsapp.net(matches hownormalize_whatsapp_identifiersplits on:).Duplicate cluster closed with credit to @sgaofen (first): #15652, #25943, #40182, #41667, #41866, plus #14738 (lid-format variant).
Validation
send("+50766715226")payload chatId+50766715226(bridge 500)50766715226@s.whatsapp.net@g.us/@lidtargets_standalone_sendpathTargeted suite: 43 tests passed (
tests/gateway/test_whatsapp_to_jid.py,tests/gateway/test_whatsapp_connect.py). E2E verified the realadapter.send()and_standalone_send()paths plus the strip→build round-trip invariant against a tempHERMES_HOME.Closes #8637.
Infographic