fix(whatsapp): strip device suffix in ID normalization#7323
Open
cosmic-hiker wants to merge 1 commit into
Open
fix(whatsapp): strip device suffix in ID normalization#7323cosmic-hiker wants to merge 1 commit into
cosmic-hiker wants to merge 1 commit into
Conversation
WhatsApp multi-device IDs use the format "number:device@domain" (e.g.
"4912345678:3@s.whatsapp.net"). The previous normalization logic used
str.replace(":", "@", 1) which produced "number@device@domain" — a
malformed ID with two @ signs.
This broke bot-self detection, mention matching, and quoted-participant
checks whenever the bot or a mentioned user had a device suffix in their
JID.
Fix: find the colon and @ positions, then slice out the ":device" segment
to produce "number@domain". Applied to both the Python adapter and the
Node.js bridge so they stay in sync.
Includes parametrized tests covering device suffixes, LID format, group
IDs, clean IDs, and edge cases.
Collaborator
|
Related to #11469 — both fix WhatsApp JID device suffix handling for group reply detection. Different approaches to the same root cause (Baileys multi-device JID format). |
This was referenced May 20, 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.
What does this PR do?
Fixes WhatsApp ID normalization for multi-device JIDs. The format is
number:device@domain(e.g.4912345678:3@s.whatsapp.net). The previous logic usedstr.replace(":", "@", 1)which producednumber@device@domain— a malformed ID with two@signs.This broke bot-self detection, mention matching, and quoted-participant checks whenever the bot or a mentioned user had a device suffix in their JID.
Fix: find the colon and
@positions, then slice out the:devicesegment to producenumber@domain. Applied to both the Python adapter and the Node.js bridge so they stay in sync.Type of Change
Changes Made
gateway/platforms/whatsapp.py—_normalize_whatsapp_id(): replace naivestr.replace(":", "@", 1)with position-based slicing that correctly strips the device suffixscripts/whatsapp-bridge/bridge.js—normalizeWhatsAppId(): same fix on the JS side so bridge and adapter stay in synctests/gateway/test_whatsapp_id_normalization.py— new parametrized test covering device suffixes, LID format, group IDs, clean IDs, and edge cases (12 cases)How to Test
pytest tests/gateway/test_whatsapp_id_normalization.py -vChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping