Skip to content

fix(whatsapp): normalize bare phone numbers to full JID for outgoing sends (#41660) - #41866

Closed
Elshayib wants to merge 2 commits into
NousResearch:mainfrom
Elshayib:fix/whatsapp-jid-normalization
Closed

fix(whatsapp): normalize bare phone numbers to full JID for outgoing sends (#41660)#41866
Elshayib wants to merge 2 commits into
NousResearch:mainfrom
Elshayib:fix/whatsapp-jid-normalization

Conversation

@Elshayib

@Elshayib Elshayib commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

WhatsApp send fails with jidDecode(...) error when using bare phone numbers (e.g. 15005004144) as targets. The bridge expects full JIDs (15005004144@s.whatsapp.net).

Root Cause

_normalize_whatsapp_id() existed for normalizing incoming message IDs but was never applied to outgoing chat_id values in send(), _send_media_to_bridge(), or send_typing().

Changes

  • gateway/platforms/whatsapp.py: Added _normalize_outgoing_chat_id() static method that appends @s.whatsapp.net to bare phone numbers (digits with optional + prefix). Full JIDs and group IDs pass through unchanged. Applied in all three outgoing methods.
  • tests/gateway/test_whatsapp_normalize_chat_id.py: 8 new tests covering bare numbers, + prefix, full JIDs, group IDs, empty strings, whitespace, and group IDs with dashes.

Validation

  • 8/8 new normalization tests pass
  • 93/93 existing WhatsApp tests pass

Fixes #41660

islam666 added 2 commits June 8, 2026 05:54
The title generation path hardcoded a 30s timeout, ignoring the
auxiliary.title_generation.timeout config value. Thread the timeout
parameter through maybe_auto_title -> auto_title_session ->
generate_title, and read the config value in gateway/run.py via
_get_task_timeout('title_generation') so user-configured values
(e.g. 300s for slow local models) are respected.

Fixes #41812
…sends

When sending WhatsApp messages via phone number targets, bare numbers
(e.g. 15005004144) were passed directly to the bridge, causing jidDecode
to fail with 'Cannot destructure property user'. The _normalize_whatsapp_id()
method existed for incoming messages but was never applied to outgoing sends.

Add _normalize_outgoing_chat_id() that appends @s.whatsapp.net to bare
phone numbers (digits with optional + prefix) and apply it in send(),
_send_media_to_bridge(), and send_typing(). Full JIDs and group IDs pass
through unchanged. 8 new tests cover the normalization logic.

Fixes #41660
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter labels Jun 8, 2026
@Elshayib

Elshayib commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

CI failure is a pre-existing infrastructure flake — curl: (22) The requested URL returned error: 504 downloading ripgrep during CI setup. Not related to this change. All other checks pass. Requesting re-run or review override.

@teknium1

Copy link
Copy Markdown
Contributor

Fixed on main via #50379 (salvage of #8639) — bare WhatsApp phone targets are now normalized to <digits>@s.whatsapp.net before the bridge call at every outbound send site.

@sgaofen's #8639 was the earliest of this cluster, so it was used as the base and credited first; thanks @Elshayib for independently catching and fixing the same bug. Closing as duplicate.

@teknium1 teknium1 closed this Jun 21, 2026
@Elshayib
Elshayib deleted the fix/whatsapp-jid-normalization branch June 22, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp send fails with bare phone number — missing @s.whatsapp.net JID suffix

3 participants