Skip to content

fix(baileys): fold neutral @c.us participant ids to engine dialect for group ops#378

Merged
rmyndharis merged 1 commit into
mainfrom
fix/baileys-group-participant-jid-dialect
Jun 20, 2026
Merged

fix(baileys): fold neutral @c.us participant ids to engine dialect for group ops#378
rmyndharis merged 1 commit into
mainfrom
fix/baileys-group-participant-jid-dialect

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

What

The engine boundary uses a neutral JID dialect (<phone>@c.us, <id>@g.us, <lid>@lid). The Baileys group-participant operations — addParticipants / removeParticipants / promoteParticipants / demoteParticipants and createGroup — passed the caller-supplied participant ids straight to groupParticipantsUpdate / groupCreate. A neutral <phone>@c.us id is then placed raw on the binary wire as an unknown c.us server suffix, instead of the single-byte s.whatsapp.net protocol token. This broke the engine's neutral-id round-trip invariant for group ops.

(1:1 messaging is unaffected — Baileys' relayMessage re-derives the destination from the decoded user part.)

Change

Fold participant ids back to the engine dialect via the existing toEngineJid transform (now reused at the adapter boundary through a small toEngineParticipants helper) before the group calls. @lid (a first-class addressing mode) and the @g.us group id are left untouched.

Preserved behaviour

  • A @s.whatsapp.net participant id (the previous shape) is idempotent through the transform.
  • getGroupInfo / getGroups still return neutral @c.us participant ids — the displayed ids are re-canonicalized from Baileys' response metadata, independent of the outbound wire dialect.
  • The whatsapp-web.js engine is deliberately untouched (@c.us is its correct native dialect).

Tests

New baileys.adapter.spec.ts cases assert that @c.us participants reach the socket as @s.whatsapp.net across all four ops and createGroup, while @lid passes through unchanged. Backend lint + build + full jest green.

…r group ops

Group-participant operations (add/remove/promote/demote and createGroup)
passed the caller-supplied participant ids straight to Baileys. A neutral
`<phone>@c.us` id encodes on the wire as an unknown 4-byte `c.us` server
suffix instead of the single-byte `s.whatsapp.net` protocol token, so these
ops broke the engine's neutral-id round-trip invariant. (1:1 sends are
unaffected because relayMessage re-derives the destination from the user
part.)

Fold participant ids back to the engine dialect via the existing
`toEngineJid` transform before the groupParticipantsUpdate/groupCreate
calls. `@lid` (a first-class addressing mode) and the `@g.us` group id are
left untouched; the returned group info stays neutral (re-canonicalized
from the response metadata), so the display contract is unchanged.
@rmyndharis rmyndharis merged commit f411bc4 into main Jun 20, 2026
5 checks passed
@rmyndharis rmyndharis deleted the fix/baileys-group-participant-jid-dialect branch June 20, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant