Skip to content

fix(#41407): recognize WhatsApp JID formats (groups, DMs, LIDs) - #41415

Closed
iamlukethedev wants to merge 1 commit into
NousResearch:mainfrom
iamlukethedev:fix/41407-whatsapp-jid-parsing
Closed

fix(#41407): recognize WhatsApp JID formats (groups, DMs, LIDs)#41415
iamlukethedev wants to merge 1 commit into
NousResearch:mainfrom
iamlukethedev:fix/41407-whatsapp-jid-parsing

Conversation

@iamlukethedev

Copy link
Copy Markdown
Contributor

Summary

Fixes two related bugs in send_message_tool._parse_target_ref:

  1. Suffixed JIDs fall through silently<digits>@g.us (group), <digits>@s.whatsapp.net (DM), <digits>@lid (LID) aren't recognized, causing silent fallback to home channel
  2. Bare digits crash the bridge — bare digits like 120363022690908060 are passed to Baileys, which crashes with 'Cannot destructure property user' error

Solution

Add WhatsApp-specific parsing in _parse_target_ref():

  • Recognize suffixed JIDs (@g.us, @s.whatsapp.net, @lid)
  • Auto-classify bare digits by length:
    • 17+ digits → @g.us (group ID)
    • 7-15 digits → @s.whatsapp.net (phone number)

Testing

  • All WhatsApp JID formats verified to parse correctly
  • Manual testing of all formats works

Fixes #41407

… LIDs)

Fixes two related bugs in send_message_tool._parse_target_ref:
1. Suffixed JIDs (@g.us, @s.whatsapp.net, @lid) fall through silently to home channel
2. Bare digits crash the bridge with 'Cannot destructure property user' error

Solution: Add WhatsApp-specific parsing logic that:
- Recognizes suffixed JIDs (@g.us groups, @s.whatsapp.net DMs, @lid LIDs)
- Auto-classifies bare digits by length:
  - 17+ digits → @g.us (group ID)
  - 7-15 digits → @s.whatsapp.net (phone number)

All WhatsApp JID formats now parse correctly.
Fixes NousResearch#41407

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Reviewed PR #41415: fix(#41407): recognize WhatsApp JID formats (groups, DMs, LIDs)

✅ Approve

  • Extends JID parsing to cover more WhatsApp messaging surface without changing integer-coded constants.
  • One-task delivery keeps regression risk low in relation to chat-routing logic.

Reviewed in batch on 2026-06-08

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused WhatsApp routing fix. This is already implemented on current main.

  • Automated hermes-sweeper review verified tools/send_message_tool.py:590-595, which recognizes @g.us, @s.whatsapp.net, and @lid WhatsApp JIDs as explicit targets, preventing home-channel fallback.
  • Bare numeric recipients are normalized before bridge delivery by gateway/whatsapp_identity.py:77-118, invoked from plugins/platforms/whatsapp/adapter.py:854.
  • The equivalent parser fix was cherry-picked with authorship preserved as ea49a79633d93202d8e495648b2586ee5a1fbecc (fix(messaging): route WhatsApp group JIDs to the target, not the home DM), released in v2026.6.19.
  • The linked fix(messaging): route WhatsApp group JIDs to the target, not the home DM #46622 discussion records the merged implementation and adds regression coverage now present in tests/tools/test_send_message_target_parse.py.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 14, 2026
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 sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] send_message WhatsApp targets: group/LID JIDs silently fall back to home channel

4 participants