Skip to content

fix(whatsapp): normalize bare phone targets to JIDs - #8639

Closed
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/whatsapp-jid-normalization
Closed

fix(whatsapp): normalize bare phone targets to JIDs#8639
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/whatsapp-jid-normalization

Conversation

@sgaofen

@sgaofen sgaofen commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • normalize bare WhatsApp phone numbers to @s.whatsapp.net JIDs before sending them to the local bridge
  • apply the normalization in both the gateway adapter and the send_message tool path
  • add regression tests covering bare-phone normalization for both direct bridge sends and adapter sends

Root Cause

Both tools/send_message_tool.py and gateway/platforms/whatsapp.py passed raw phone numbers directly to the Baileys bridge. Baileys expects a WhatsApp JID like 50766715226@s.whatsapp.net, so bare numbers caused jidDecode(...) to return undefined and the bridge crashed with HTTP 500.

Closes #8637.

Testing

  • python3 -m py_compile gateway/platforms/whatsapp.py tools/send_message_tool.py tests/gateway/test_whatsapp_connect.py tests/tools/test_send_message_tool.py
  • uv run --extra dev pytest tests/gateway/test_whatsapp_connect.py -q
  • uv run --extra dev pytest tests/tools/test_send_message_tool.py -q -k 'whatsapp'

Platform Tested

  • macOS 15.x (Apple Silicon)

Contribution Guide Notes

  • Reviewed CONTRIBUTING.md and checked for existing open PRs before submitting this scoped bug fix.
  • Ran the targeted verification commands listed above for this PR. I have not claimed a full repo-wide pytest tests/ -q pass unless explicitly noted.

@sgaofen sgaofen changed the title [codex] normalize bare WhatsApp phone targets to JIDs fix(whatsapp): normalize bare phone targets to JIDs Apr 12, 2026
@sgaofen
sgaofen marked this pull request as ready for review April 13, 2026 00:51
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Superseded by #15652 which addresses the same bare-phone JID normalization at both gateway and bridge layers. Both close #8637.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Superseded by #15652 which addresses the same bare-phone JID normalization at both gateway and bridge layers. Both close #8637.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #50379. Your fix was cherry-picked onto current main with your authorship preserved in git history (commit a4b1554).

The adapter had been migrated to a bundled plugin and the WhatsApp identity helpers extracted since you opened this, so the normalizer now lives in gateway/whatsapp_identity.py as to_whatsapp_jid() (the outbound inverse of normalize_whatsapp_identifier) and is wired at all six outbound bridge sites. One tweak on top: the :device@domain legacy form now collapses correctly instead of producing a double-@. Thanks for the fix and the tests!

@teknium1 teknium1 closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery 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 bridge crashes on bare phone numbers — missing JID normalization

3 participants