Skip to content

fix(reaction): populate _serialized on reaction msg keys - #201847

Open
rmyndharis wants to merge 1 commit into
wwebjs:mainfrom
rmyndharis:fix/reaction-serialized-id
Open

fix(reaction): populate _serialized on reaction msg keys#201847
rmyndharis wants to merge 1 commit into
wwebjs:mainfrom
rmyndharis:fix/reaction-serialized-id

Conversation

@rmyndharis

Copy link
Copy Markdown

Closes #201846.

What

Reaction assigns both of its keys straight through from data:

this.id = data.msgKey;          // Reaction.js:21
this.msgId = data.parentMsgKey; // Reaction.js:51

On the July 2026 WhatsApp Web build those keys carry $1 instead of _serialized, so reaction.id._serialized and reaction.msgId._serialized are undefined — while index.d.ts types both as MessageId, whose _serialized is not optional. Consumers read it directly and get nothing back, silently.

It's the only Base subclass whose ids aren't named data.id, which is why the sweep in #201832 doesn't reach it. That PR does fix senderUserJid in the same reaction handler, but these two keys are passed through as objects rather than read, so there was no _serialized access there to catch.

How

Normalizes both keys, leaving an already-serialized key untouched. Independent of #201832 — it doesn't use Base._normalizeId, so it applies to main as-is and the two can land in either order. If #201832 lands first and you'd rather this delegate to Base._normalizeId, happy to rebase it that way.

Verified

build result
$1 only msgId._serialized'true_1@c.us_M1'; remote / fromMe / id preserved
_serialized present identity — same object reference, no copy
key undefined no throw

Notes

Found while tracking the rename downstream in a project that uses this library. The message_reaction path was the one that stayed broken after applying the #201832 changes, which is what led here. Also visible from the outside in the workaround script in #201829, which patches reaction.msgId._serialized on the consumer side.

WhatsApp Web's July 2026 build renamed MsgKey's `_serialized` property to the
minified `$1`. Reaction assigns both of its keys straight through from data
(`msgKey`, `parentMsgKey`), so `reaction.id._serialized` and
`reaction.msgId._serialized` come back undefined on that build, even though
index.d.ts types both as MessageId, whose `_serialized` is not optional.

Reaction is the only Base subclass whose ids are named something other than
`data.id`, which is why a sweep for `this.id = data.id` doesn't reach it.

Normalize both keys the same way the sibling structures handle theirs. Leaves
an already-serialized key untouched, so builds that still send `_serialized`
are unaffected.
@github-actions github-actions Bot added the api changes API modifications label Jul 16, 2026
rmyndharis added a commit to rmyndharis/OpenWA that referenced this pull request Jul 16, 2026
…#747)

WhatsApp Web build 2.3000.x (~2026-07-14) renamed the serialized message-id property `id._serialized` to `id.$1`, breaking whatsapp-web.js 1.34.7's downloadMedia(), message-id extraction, ack tracking, and quoted-message resolution for every bot at once.

The production image and source installs now backport upstream fix wwebjs/whatsapp-web.js#201832 (Base._normalizeId) into the dependency at build time. The patcher applies the real upstream diff, fails the build loudly on version skew rather than shipping a partial patch, and auto-disables once a whatsapp-web.js release carries the fix upstream. Stopgap, not a fork — it gets removed with the dep bump.

Verified against a live session on an affected build (2.3000.1043250633-alpha): inbound photos download with bytes intact (223KB/1200x1600 and 75KB/1600x900 JPEGs), message ids resolve, the reply endpoint accepts a live quotedMessageId, getChats returns valid ids, and no media-download errors fire.

Reactions remain unattributable on these builds — Reaction is the one structure upstream's fix doesn't reach. Reported as wwebjs/whatsapp-web.js#201846 with a fix in wwebjs/whatsapp-web.js#201847; an adapter-side fallback here keeps reaction events from attaching to the wrong message meanwhile.

Fixes #747.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api changes API modifications

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reaction msg keys keep _serialized undefined on the $1-rename builds

1 participant