Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(groups): pass the description job the options object the page takes

Suryac61c2d8edb50
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 075973384..f432c8780 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- `PUT /sessions/{sessionId}/groups/{groupId}/description` no longer fails with a bare `500` on
+ whatsapp-web.js. `WAWebGroupModifyInfoJob.setGroupDescription` now takes a single options object
+ and the library still calls it positionally, so `widToGroupJid` threw inside the page. A new
+ install-time patch (πŸ”§βΉ, docs/29) sends the options object; an empty description still clears.
+ `setGroupSubject` was never affected and Baileys is unchanged.
- Inbound media whose download fails now keeps the `media` envelope with `omitted: true` and the declared
size, on both engines, instead of dropping the field and looking like a message that never had media.
- Webhook filters and automation rules gated on `hasMedia` now match those messages.
diff --git a/Dockerfile b/Dockerfile
index c3aae9c16..8bafbe462 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -174,7 +174,7 @@ COPY package*.json ./
# scripts/postinstall.js rides along so a bare local `npm ci` keeps working, but the
# --ignore-scripts install below skips the hook here: the explicit fatal run right
# after is the sole (and stricter) applier for the image.
-COPY scripts/postinstall.js scripts/patch-wwebjs-201832.js scripts/wwebjs-201832.patch scripts/patch-wwebjs-newsletter-preview.js scripts/patch-wwebjs-status.js scripts/patch-wwebjs-ready-sync.js scripts/patch-wwebjs-participant-arity.js scripts/patch-wwebjs-block.js scripts/patch-baileys-appstate.js scripts/patch-baileys-newsletter-create.js ./scripts/
+COPY scripts/postinstall.js scripts/patch-wwebjs-201832.js scripts/wwebjs-201832.patch scripts/patch-wwebjs-newsletter-preview.js scripts/patch-wwebjs-status.js scripts/patch-wwebjs-ready-sync.js scripts/patch-wwebjs-participant-arity.js scripts/patch-wwebjs-block.js scripts/patch-wwebjs-group-description.js scripts/patch-baileys-appstate.js scripts/patch-baileys-newsletter-create.js ./scripts/
# Install production dependencies only, then apply the backports. The status patcher runs after
# the two patchers it depends on: its transforms were written against the tree they leave behind.
@@ -197,6 +197,7 @@ RUN npm ci --omit=dev --ignore-scripts \
&& node scripts/patch-wwebjs-ready-sync.js \
&& node scripts/patch-wwebjs-participant-arity.js \
&& node scripts/patch-wwebjs-block.js \
+ && node scripts/patch-wwebjs-group-description.js \
&& node scripts/patch-baileys-appstate.js \
&& node scripts/patch-baileys-newsletter-create.js \
&& npm cache clean --force
diff --git a/docs/29-engine-capability-matrix.md b/docs/29-engine-capability-matrix.md
index ee742c79c..0df586728 100644
--- a/docs/29-engine-capability-matrix.md
+++ b/docs/29-engine-capability-matrix.md
@@ -5,7 +5,7 @@ Three-way comparison of every capability: the **Baileys library** (`@whiskeysock
its adapter layer and REST API β€” including which "supported" cells only work because OpenWA patches
the installed library. Coverage is total: all 112 `IWhatsAppEngine` methods (29.4), **all 152
Baileys + 81 whatsapp-web.js library methods** (29.5), all 34 + 31 library events (29.5.4), and all
-8 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.
+9 install-time patches (29.3). If it exists upstream or in OpenWA, it has a row here.
## 29.1 How to read this matrix
@@ -49,7 +49,7 @@ flowchart LR
IF --> BA["BaileysAdapter"]
SVC --> STORE["OpenWA-side stores"]
end
- WA --> WLIB["whatsapp-web.js 1.34.7<br/>+ 6 OpenWA patches"]
+ WA --> WLIB["whatsapp-web.js 1.34.7<br/>+ 7 OpenWA patches"]
BA --> BLIB["@whiskeysockets/baileys 7.0.0-rc13<br/>+ 2 OpenWA patches"]
WLIB --> WEB["WhatsApp Web<br/>headless Chromium"]
BLIB --> WAS["WhatsApp servers<br/>browser-free socket"]
@@ -125,7 +125,7 @@ wrong interface method. Those three remain reader-verified.
## 29.3 Install-time patches OpenWA applies to the libraries
-OpenWA ships eight exact, self-disabling source transforms over the installed engines. Each runs at
+OpenWA ships nine exact, self-disabling source transforms over the installed engines. Each runs at
`npm install` (`scripts/postinstall.js`, `--best-effort`) and again in the Docker production stage
(**without** best-effort β€” dependency drift fails the image build). "Self-disabling" means the
patcher no-ops once the fix is present upstream, and an unrecognized source shape fails loudly
@@ -133,20 +133,21 @@ rather than shipping a silently partial patch.
### 29.3.1 The eight patches
-| # | Patcher | Library target | What it repairs | Stand-down predicate |
-| --- | ---------------------------------------------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| πŸ”§ΒΉ | `scripts/patch-wwebjs-201832.js` (+ `wwebjs-201832.patch`) | whatsapp-web.js models | WhatsApp Web 2.3000.x renamed the serialized message-id property `id._serialized` β†’ `id.$1`; 1.34.7 reads the old name in the `Message` constructor and ~40 downstream sites, so message ids, acks, quoted-message resolution and media downloads break. Backports upstream fix #201832 (`Base._normalizeId()`). One known harmless reject on 1.34.7 (a LID-aware `Contact.js` path that does not exist there); any other reject aborts the build. | no-ops once `_normalizeId` exists upstream. Runtime double-check: `src/engine/adapters/wwebjs-backport-check.ts` detects an unpatched install and logs an error naming the fix as the wwjs session starts (`whatsapp-web-js.adapter.ts:446`). It is diagnostic, **not** preventive β€” startup continues, so a session reaching READY is not evidence the patch landed. |
-| πŸ”§Β² | `scripts/patch-wwebjs-status.js` | whatsapp-web.js injected status send | Two independent breakages in current WhatsApp Web builds: (1) the `canCheckStatusRankingPosterGating()` helper is gone and its call threw before any status send β€” now called when present, `false` (pre-gating meaning) when not; (2) `sendStatusMediaMsgAction` changed signature from positional `(msg, mediaUpdate)` to a single options object β€” adopted from upstream PR #201816. The two edits of the media repair are all-or-nothing. | exact-shape match; unknown shape fails the build. |
-| πŸ”§Β³ | `scripts/patch-wwebjs-newsletter-preview.js` | whatsapp-web.js `Injected/Utils.js` | Link-preview generation omitted the destination chat, so WhatsApp Web could not select the newsletter preview transport: `getLinkPreview(link)` β†’ `getLinkPreview(link, chat)`. | exact-shape match; unknown shape fails the build. |
-| πŸ”§β΄ | `scripts/patch-wwebjs-ready-sync.js` | whatsapp-web.js readiness pipeline | Two live-observed races: on a warm profile the page can reach `hasSynced=true` before the edge listener attaches (the whole post-auth pipeline silently never runs), and a partial `attachEventListeners` failure was swallowed (message bridge dead while sends still work). Adds an `eventsAttached` completion marker and fires the handler once when the level is already true; double-fire is deduped by the adapter. | exact-shape, one group all-or-nothing; unknown shape fails the build. |
-| πŸ”§β΅ | `scripts/patch-baileys-appstate.js` | Baileys `lib/Socket/chats.js` | `resyncAppState`'s `while (collectionsToHandle.size)` loop: `query()` resolves `undefined` on its own 60s timeout, decoding to `{}`, and every loop exit β€” including the library's own attempts guard β€” lives inside `for (const key in decoded)`, which never runs on an empty decode. The loop would burn one 60s query per pass for the life of the socket (~1000 wasted queries/day). The patch adds the missing exit: empty decode β†’ `break`. | exact-shape match; remove once upstream bounds the loop. |
-| πŸ”§βΆ | `scripts/patch-baileys-newsletter-create.js` | Baileys `lib/Socket/newsletter.js` | `parseNewsletterCreateResponse` reads `thread.picture.id` eagerly, but `newsletterCreate` sends only `{ name, description }` β€” there is no picture parameter anywhere in the chain β€” so `thread.picture` is null on EVERY create and the parse threw for all of them. WhatsApp creates the newsletter server-side BEFORE the response is parsed, so each call returned 500 while leaving a real channel behind, and `createChannel` is non-idempotent, so a client retrying a 5xx leaked one orphan per attempt (confirmed on the test account). `description` has the same defect whenever the caller omits one. The patch reads every nested field defensively so the response's `id` β€” the only place the new channel's id appears β€” always survives. | exact-shape match; remove once upstream tolerates a pictureless newsletter. |
-| πŸ”§β· | `scripts/patch-wwebjs-participant-arity.js` | whatsapp-web.js `GroupChat.js` | `removeParticipants`/`promoteParticipants`/`demoteParticipants` resolve each requested id against the group's own member collection and drop what they cannot find, then resolve `{status: 200}` for the batch. Dropping EVERY id left the WA Web request builder an empty repeated field, whose arity assertion threw β€” the caller saw an unnamed `500` on removal. Promote and demote have no such assertion, so they answered `200` claiming success for people WhatsApp never touched. The patch keeps the resolved array with its holes, skips the call when nothing resolved, and returns `matched` (one boolean per REQUESTED id) so the adapter can report a per-participant outcome instead of inventing one. | exact-shape match; remove once upstream reports which participants it acted on. |
-| πŸ”§βΈ | `scripts/patch-wwebjs-block.js` | whatsapp-web.js `Contact.js` | `Contact.block()`/`unblock()` resolved their target through `getContactToBlockOnlyUseIfNoAssociatedChat`, which WhatsApp Web removed, so both answered an opaque `500` for every id shape. The replacement helpers `handleBlock`/`handleUnblock` are modal-driven UI wrappers that block nothing when called headless, and the server now refuses a phone-keyed block outright (`trying to block a pn contact without a chat`) because individual chats are keyed by LID while wwjs folds every id back to a phone number. Resolves through `WAWebLidMigrationUtils.toUserLid` to the chat-owning identity and calls `blockContact`/`unblockContact` directly, falling back to the original contact when no LID or chat exists. | exact-shape match on both bodies; unknown shape fails the build. |
+| # | Patcher | Library target | What it repairs | Stand-down predicate |
+| --- | ---------------------------------------------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| πŸ”§ΒΉ | `scripts/patch-wwebjs-201832.js` (+ `wwebjs-201832.patch`) | whatsapp-web.js models | WhatsApp Web 2.3000.x renamed the serialized message-id property `id._serialized` β†’ `id.$1`; 1.34.7 reads the old name in the `Message` constructor and ~40 downstream sites, so message ids, acks, quoted-message resolution and media downloads break. Backports upstream fix #201832 (`Base._normalizeId()`). One known harmless reject on 1.34.7 (a LID-aware `Contact.js` path that does not exist there); any other reject aborts the build. | no-ops once `_normalizeId` exists upstream. Runtime double-check: `src/engine/adapters/wwebjs-backport-check.ts` detects an unpatched install and logs an error naming the fix as the wwjs session starts (`whatsapp-web-js.adapter.ts:446`). It is diagnostic, **not** preventive β€” startup continues, so a session reaching READY is not evidence the patch landed. |
+| πŸ”§Β² | `scripts/patch-wwebjs-status.js` | whatsapp-web.js injected status send | Two independent breakages in current WhatsApp Web builds: (1) the `canCheckStatusRankingPosterGating()` helper is gone and its call threw before any status send β€” now called when present, `false` (pre-gating meaning) when not; (2) `sendStatusMediaMsgAction` changed signature from positional `(msg, mediaUpdate)` to a single options object β€” adopted from upstream PR #201816. The two edits of the media repair are all-or-nothing. | exact-shape match; unknown shape fails the build. |
+| πŸ”§Β³ | `scripts/patch-wwebjs-newsletter-preview.js` | whatsapp-web.js `Injected/Utils.js` | Link-preview generation omitted the destination chat, so WhatsApp Web could not select the newsletter preview transport: `getLinkPreview(link)` β†’ `getLinkPreview(link, chat)`. | exact-shape match; unknown shape fails the build. |
+| πŸ”§β΄ | `scripts/patch-wwebjs-ready-sync.js` | whatsapp-web.js readiness pipeline | Two live-observed races: on a warm profile the page can reach `hasSynced=true` before the edge listener attaches (the whole post-auth pipeline silently never runs), and a partial `attachEventListeners` failure was swallowed (message bridge dead while sends still work). Adds an `eventsAttached` completion marker and fires the handler once when the level is already true; double-fire is deduped by the adapter. | exact-shape, one group all-or-nothing; unknown shape fails the build. |
+| πŸ”§β΅ | `scripts/patch-baileys-appstate.js` | Baileys `lib/Socket/chats.js` | `resyncAppState`'s `while (collectionsToHandle.size)` loop: `query()` resolves `undefined` on its own 60s timeout, decoding to `{}`, and every loop exit β€” including the library's own attempts guard β€” lives inside `for (const key in decoded)`, which never runs on an empty decode. The loop would burn one 60s query per pass for the life of the socket (~1000 wasted queries/day). The patch adds the missing exit: empty decode β†’ `break`. | exact-shape match; remove once upstream bounds the loop. |
+| πŸ”§βΆ | `scripts/patch-baileys-newsletter-create.js` | Baileys `lib/Socket/newsletter.js` | `parseNewsletterCreateResponse` reads `thread.picture.id` eagerly, but `newsletterCreate` sends only `{ name, description }` β€” there is no picture parameter anywhere in the chain β€” so `thread.picture` is null on EVERY create and the parse threw for all of them. WhatsApp creates the newsletter server-side BEFORE the response is parsed, so each call returned 500 while leaving a real channel behind, and `createChannel` is non-idempotent, so a client retrying a 5xx leaked one orphan per attempt (confirmed on the test account). `description` has the same defect whenever the caller omits one. The patch reads every nested field defensively so the response's `id` β€” the only place the new channel's id appears β€” always survives. | exact-shape match; remove once upstream tolerates a pictureless newsletter. |
+| πŸ”§β· | `scripts/patch-wwebjs-participant-arity.js` | whatsapp-web.js `GroupChat.js` | `removeParticipants`/`promoteParticipants`/`demoteParticipants` resolve each requested id against the group's own member collection and drop what they cannot find, then resolve `{status: 200}` for the batch. Dropping EVERY id left the WA Web request builder an empty repeated field, whose arity assertion threw β€” the caller saw an unnamed `500` on removal. Promote and demote have no such assertion, so they answered `200` claiming success for people WhatsApp never touched. The patch keeps the resolved array with its holes, skips the call when nothing resolved, and returns `matched` (one boolean per REQUESTED id) so the adapter can report a per-participant outcome instead of inventing one. | exact-shape match; remove once upstream reports which participants it acted on. |
+| πŸ”§βΈ | `scripts/patch-wwebjs-block.js` | whatsapp-web.js `Contact.js` | `Contact.block()`/`unblock()` resolved their target through `getContactToBlockOnlyUseIfNoAssociatedChat`, which WhatsApp Web removed, so both answered an opaque `500` for every id shape. The replacement helpers `handleBlock`/`handleUnblock` are modal-driven UI wrappers that block nothing when called headless, and the server now refuses a phone-keyed block outright (`trying to block a pn contact without a chat`) because individual chats are keyed by LID while wwjs folds every id back to a phone number. Resolves through `WAWebLidMigrationUtils.toUserLid` to the chat-owning identity and calls `blockContact`/`unblockContact` directly, falling back to the original contact when no LID or chat exists. | exact-shape match on both bodies; unknown shape fails the build. |
+| πŸ”§βΉ | `scripts/patch-wwebjs-group-description.js` | whatsapp-web.js `GroupChat.js` | `GroupChat.setDescription()` calls the page's `WAWebGroupModifyInfoJob.setGroupDescription(chatWid, description, newId, descId)` positionally, but that job now takes a single options object `{desc, groupWid, newDescId, prevDescId}`. The first positional argument lands where the object is read, every field comes back undefined, and `widToGroupJid(undefined)` throws inside the page β€” reaching the caller as a bare `500` while the library still types the method `Promise<boolean>`. `setGroupSubject` in the same module is still positional, which is why subjects kept working and made the Wid look innocent. The patch sends the options object, takes `newDescId` from `WARandomHex.randomHex(8)` as the product does, and maps an empty description to `desc: null` so it selects the job's delete branch rather than sending an empty body element. | exact-shape match; unknown shape fails the build. |
### 29.3.2 Which matrix rows depend on which patch
-This is the patch visibility the matrix cells refer to. Every patch is engine-specific (6 on wwjs,
+This is the patch visibility the matrix cells refer to. Every patch is engine-specific (7 on wwjs,
2 on Baileys), and **no row carries a row-level patch mark on both engines**. The two column-wide
patches are a separate matter: πŸ”§ΒΉ underwrites every wwjs cell and πŸ”§β΅ every baileys cell, so in
that sense every row does depend on a patch on each side. "Patch-dependent" below means the
@@ -161,12 +162,13 @@ row-level marks.
| πŸ”§β΅ app-state resync bound | No single row β€” keeps the Baileys socket's app-state resync from spinning (~1000 wasted 60s queries/day). Connection health under **every baileys cell**; the baileys column header carries `πŸ”§β΅`. |
| πŸ”§βΆ newsletter-create parse | `createChannel` on **baileys** β€” without it the call always answers 500 and leaks the channel it just created. Row-marked. |
| πŸ”§β· participant arity | `removeParticipants`, `promoteParticipants`, `demoteParticipants` on **wwjs**. Without it a request naming only non-members throws an arity assertion on removal, and promote/demote answer `200` for people WhatsApp never touched; the patch returns one boolean per REQUESTED id so the adapter reports a real per-participant outcome. Row-marked. |
+| πŸ”§βΉ group description | `setGroupDescription` on **wwjs**. Without it every call throws in the page and answers a bare `500`, so the capability is dead rather than degraded; `setGroupSubject` beside it is unaffected. Row-marked. |
| πŸ”§βΈ block/unblock | `blockContact`, `unblockContact` on **wwjs**. Without it both answer an opaque `500` on every id, so the capability is dead rather than degraded; the blocklist read still works, which makes the failure look one-sided. |
Rows that are βœ… on **both** engines where one side is patch-dependent: `initialize` (πŸ”§β΄ wwjs),
`sendTextMessage` (πŸ”§Β³ wwjs), `postTextStatus` / `postImageStatus` / `postVideoStatus` /
`postVoiceStatus` (πŸ”§Β² wwjs), `removeParticipants` / `promoteParticipants` / `demoteParticipants`
-(πŸ”§β· wwjs). Everything else that is βœ…-both carries no row-level mark, but still
+(πŸ”§β· wwjs), `setGroupDescription` (πŸ”§βΉ wwjs). Everything else that is βœ…-both carries no row-level mark, but still
rests on the column-wide πŸ”§ΒΉ (wwjs) and πŸ”§β΅ (baileys) β€” no row runs on stock library code on both
sides.
@@ -307,7 +309,7 @@ socket is caught by the transport instead. No REST route: the session watchdog p
| `revokeGroupInviteCode` | βœ… | βœ… | βœ… |
| `getGroupJoinInfo` | βœ… | βœ… | βœ… |
| `setGroupSubject` | βœ… | βœ… | βœ… |
-| `setGroupDescription` | βœ… | βœ… | βœ… |
+| `setGroupDescription` | βœ… | βœ…πŸ”§βΉ | βœ… |
| `setGroupPicture` | βœ… | βœ… | βœ… |
| `deleteGroupPicture` | βœ… | βœ… | βœ… |
| `setGroupMessagesAdminsOnly` | βœ… | βœ… | βœ… |
@@ -949,8 +951,9 @@ adapter sources β€” re-derive the same way when anything changes:
- **112** interface methods β†’ **224** adapter cells: **199 βœ…** / **25 ❌** (2 adapter-gaps, 23
library-limitations, 0 uncertain), spanning **24** methods.
-- Of the 199 βœ… cells, **9 wwjs cells carry an explicit patch dependency** (4 Γ— πŸ”§Β² status send,
- 1 Γ— πŸ”§Β³ channel link preview, 1 Γ— πŸ”§β΄ ready-sync, 3 Γ— πŸ”§β· participant arity) and one baileys cell
+- Of the 199 βœ… cells, **10 wwjs cells carry an explicit patch dependency** (4 Γ— πŸ”§Β² status send,
+ 1 Γ— πŸ”§Β³ channel link preview, 1 Γ— πŸ”§β΄ ready-sync, 3 Γ— πŸ”§β· participant arity, 1 Γ— πŸ”§βΉ group
+ description) and one baileys cell
does (1 Γ— πŸ”§βΆ newsletter-create parse); the whole wwjs column additionally
depends on πŸ”§ΒΉ, the whole Baileys column on πŸ”§β΅ β€” so every row rests on a patch on each side,
even though no row carries a row-level mark on both.
@@ -969,7 +972,7 @@ adapter sources β€” re-derive the same way when anything changes:
provides, and `transferChannelOwnership`, whose page function rejects locally against a
subscriber list it cannot repopulate (both in 29.6.2). Both answer 501 on wwjs. `.d.ts` presence
is not capability, and only a live call distinguishes the two.
-- **8** install-time patches (6 whatsapp-web.js + 2 Baileys), all exact and self-disabling.
+- **9** install-time patches (7 whatsapp-web.js + 2 Baileys), all exact and self-disabling.
- **0 phantom-support rows** β€” every `not-available` cell throws at the adapter boundary.
- Remaining adapter-gaps (fixable in this repo, ranked): **#1** `getChannelMessages` (Baileys β€”
fetch is one line, `BinaryNode`β†’`ChannelMessage` parser is the work); **#2** `subscribeToChannel`
diff --git a/package.json b/package.json
index b97c46000..f83d119e8 100644
--- a/package.json
+++ b/package.json
@@ -41,7 +41,7 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
- "test:scripts": "node --test scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/dockerfile-patchers.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs",
+ "test:scripts": "node --test scripts/postinstall.spec.js scripts/patch-wwebjs-newsletter-preview.spec.js scripts/patch-wwebjs-status.spec.js scripts/patch-wwebjs-ready-sync.spec.js scripts/patch-wwebjs-participant-arity.spec.js scripts/patch-wwebjs-block.spec.js scripts/patch-wwebjs-group-description.spec.js scripts/patch-baileys-appstate.spec.js scripts/patch-baileys-newsletter-create.spec.js scripts/dockerfile-patchers.spec.js scripts/check-upstream-surface.spec.mjs scripts/check-sdk-docs.spec.mjs scripts/check-audit.spec.mjs scripts/check-contract-shapes.spec.mjs",
"test:docs": "jest src/common/changelog-sections.spec.ts src/common/ci-privilege-gate.spec.ts src/common/docs-ci-jobs.spec.ts src/common/docs-coverage-policy.spec.ts src/common/docs-metrics-list.spec.ts src/common/openapi/docs-06-contract.spec.ts src/common/test-lane-partition.spec.ts src/config/docs-env-example.spec.ts src/config/openapi-contract.spec.ts src/config/openapi-export-pins.spec.ts src/config/wa-web-version-example-pin.spec.ts src/engine/docs-29-counts.spec.ts src/engine/engine-inventory-parity.spec.ts src/engine/engine-parity.spec.ts src/engine/inventory-mapping-direction.spec.ts src/engine/adapters/baileys-voice-waveform.spec.ts src/engine/adapters/wwebjs-newsletter-preview.spec.ts src/modules/audit/audit-coverage.spec.ts src/modules/auth/global-route-fence-coverage.spec.ts src/modules/auth/query-session-scope-coverage.spec.ts src/modules/docker/compose-network.spec.ts src/modules/queue/bull-board-mount-coverage.spec.ts src/common/release-gate-parity.spec.ts src/database/migrations/__tests__/migration-drift.spec.ts --testPathIgnorePatterns=/node_modules/",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
diff --git a/scripts/patch-wwebjs-group-description.js b/scripts/patch-wwebjs-group-description.js
new file mode 100644
index 000000000..9a96e430c
--- /dev/null
+++ b/scripts/patch-wwebjs-group-description.js
@@ -0,0 +1,93 @@
+/**
+ * Pass the group description job the options object WhatsApp Web now takes.
+ *
+ * `WAWebGroupModifyInfoJob.setGroupDescription` takes a single `{desc, groupWid, newDescId,
+ * prevDescId}`. The released whatsapp-web.js 1.34.7 calls it positionally, so the Wid lands where
+ * the object is read, every field is undefined, and `widToGroupJid` throws inside the page β€”
+ * reaching the caller as a bare 500 while the library still types the method `Promise<boolean>`.
+ * `setGroupSubject` in the same module is still positional and is unaffected.
+ *
+ * The description id comes from `WARandomHex.randomHex(8)` and an empty description is sent as
+ * `null`, both as WhatsApp Web itself does: `null` selects the job's delete branch, so `''` still
+ * clears rather than writing an empty body element.
+ *
+ * The source transform is deliberately exact and self-disabling. An unknown shape fails the
+ * production image build instead of silently shipping without the fix.
+ */
+'use strict';
+
+const fs = require('fs');
+const path = require('path');
+
+const DEFAULT_WWJS = path.join(__dirname, '..', 'node_modules', 'whatsapp-web.js');
+const GROUP_CHAT_PATH = path.join('src', 'structures', 'GroupChat.js');
+const POSITIONAL_CALL = ` let newId = await window.require('WAWebMsgKey').newId();
+ try {
+ await window
+ .require('WAWebGroupModifyInfoJob')
+ .setGroupDescription(
+ chatWid,
+ description,
+ newId,
+ descId,
+ );`;
+const OPTIONS_CALL = ` let newId = window.require('WARandomHex').randomHex(8);
+ try {
+ await window
+ .require('WAWebGroupModifyInfoJob')
+ .setGroupDescription({
+ desc: description === '' ? null : description,
+ groupWid: chatWid,
+ newDescId: newId,
+ prevDescId: descId,
+ });`;
+
+function occurrences(source, needle) {
+ return source.split(needle).length - 1;
+}
+
+function applyGroupDescriptionFix(wwjsDir = DEFAULT_WWJS) {
+ const groupChatFile = path.join(wwjsDir, GROUP_CHAT_PATH);
+ if (!fs.existsSync(groupChatFile)) {
+ throw new Error(`whatsapp-web.js GroupChat.js not found at ${groupChatFile}`);
+ }
+
+ const source = fs.readFileSync(groupChatFile, 'utf8');
+ const positionalCount = occurrences(source, POSITIONAL_CALL);
+ const optionsCount = occurrences(source, OPTIONS_CALL);
+
+ if (positionalCount === 0 && optionsCount === 1) {
+ return {
+ skipped: true,
+ reason: 'installed whatsapp-web.js already calls the description job with an options object',
+ };
+ }
+ if (positionalCount !== 1 || optionsCount !== 0) {
+ throw new Error(
+ `unsupported GroupChat.js shape (positional calls: ${positionalCount}, options calls: ${optionsCount}); ` +
+ 're-evaluate the group description fix against the installed whatsapp-web.js',
+ );
+ }
+
+ fs.writeFileSync(groupChatFile, source.replace(POSITIONAL_CALL, OPTIONS_CALL));
+ return { skipped: false, note: 'group description job called with an options object' };
+}
+
+function run() {
+ const bestEffort = process.argv.includes('--best-effort');
+ try {
+ const result = applyGroupDescriptionFix();
+ console.log(`patch-wwebjs-group-description: ${result.skipped ? `skipped β€” ${result.reason}` : result.note}`);
+ } catch (error) {
+ if (bestEffort) {
+ console.warn(`patch-wwebjs-group-description: skipped β€” ${error.message}`);
+ return;
+ }
+ console.error(`patch-wwebjs-group-description: ${error.message}`);
+ process.exitCode = 1;
+ }
+}
+
+if (require.main === module) run();
+
+module.exports = { applyGroupDescriptionFix, POSITIONAL_CALL, OPTIONS_CALL };
diff --git a/scripts/patch-wwebjs-group-description.spec.js b/scripts/patch-wwebjs-group-description.spec.js
new file mode 100644
index 000000000..84535fa7d
--- /dev/null
+++ b/scripts/patch-wwebjs-group-description.spec.js
@@ -0,0 +1,77 @@
+'use strict';
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const fs = require('fs');
+const os = require('os');
+const path = require('path');
+
+const { applyGroupDescriptionFix, POSITIONAL_CALL, OPTIONS_CALL } = require('./patch-wwebjs-group-description.js');
+
+function makeDependency(source) {
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openwa-group-description-'));
+ const groupChat = path.join(root, 'src', 'structures', 'GroupChat.js');
+ fs.mkdirSync(path.dirname(groupChat), { recursive: true });
+ fs.writeFileSync(groupChat, source);
+ return { root, groupChat };
+}
+
+test('patches the description job call to the options object', () => {
+ const { root, groupChat } = makeDependency(`before\n${POSITIONAL_CALL}\nafter\n`);
+
+ const result = applyGroupDescriptionFix(root);
+
+ assert.deepEqual(result, { skipped: false, note: 'group description job called with an options object' });
+ assert.equal(fs.readFileSync(groupChat, 'utf8'), `before\n${OPTIONS_CALL}\nafter\n`);
+});
+
+test('sends an empty description as null, which clears rather than writing an empty body', () => {
+ const { root, groupChat } = makeDependency(`before\n${POSITIONAL_CALL}\nafter\n`);
+
+ applyGroupDescriptionFix(root);
+
+ assert.match(fs.readFileSync(groupChat, 'utf8'), /desc: description === '' \? null : description/);
+});
+
+test('is idempotent when the options object is already present', () => {
+ const { root, groupChat } = makeDependency(`before\n${OPTIONS_CALL}\nafter\n`);
+ const original = fs.readFileSync(groupChat, 'utf8');
+
+ assert.deepEqual(applyGroupDescriptionFix(root), {
+ skipped: true,
+ reason: 'installed whatsapp-web.js already calls the description job with an options object',
+ });
+ assert.equal(fs.readFileSync(groupChat, 'utf8'), original);
+});
+
+test('rejects an unknown dependency shape without changing it', () => {
+ const { root, groupChat } = makeDependency('module.exports = class GroupChat {};\n');
+ const original = fs.readFileSync(groupChat, 'utf8');
+
+ assert.throws(() => applyGroupDescriptionFix(root), /unsupported GroupChat\.js shape/);
+ assert.equal(fs.readFileSync(groupChat, 'utf8'), original);
+});
+
+test('rejects an ambiguous dependency shape without changing it', () => {
+ const { root, groupChat } = makeDependency(`${POSITIONAL_CALL}\n${OPTIONS_CALL}\n`);
+ const original = fs.readFileSync(groupChat, 'utf8');
+
+ assert.throws(() => applyGroupDescriptionFix(root), /unsupported GroupChat\.js shape/);
+ assert.equal(fs.readFileSync(groupChat, 'utf8'), original);
+});
+
+test('reports a missing dependency tree', () => {
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'openwa-group-description-empty-'));
+
+ assert.throws(() => applyGroupDescriptionFix(root), /GroupChat\.js not found/);
+});
+
+test('matches the call shape the installed whatsapp-web.js ships', () => {
+ const installed = path.join(__dirname, '..', 'node_modules', 'whatsapp-web.js', 'src', 'structures', 'GroupChat.js');
+ const source = fs.readFileSync(installed, 'utf8');
+
+ assert.ok(
+ source.includes(POSITIONAL_CALL) || source.includes(OPTIONS_CALL),
+ 'installed GroupChat.js matches neither the upstream call nor the patched one',
+ );
+});
diff --git a/scripts/postinstall.js b/scripts/postinstall.js
index c440355c9..938d6e301 100644
--- a/scripts/postinstall.js
+++ b/scripts/postinstall.js
@@ -1,7 +1,7 @@
/**
* Post-install hook (npm `postinstall`).
*
- * Eight conditional steps, each skipped when its target is absent so the hook is a no-op where the
+ * Ten conditional steps, each skipped when its target is absent so the hook is a no-op where the
* piece is missing (the Docker builder stage copies package*.json long before any source):
*
* 1. `npm ci` inside dashboard/ when dashboard/ exists β€” the dashboard carries its own lockfile and
@@ -25,11 +25,13 @@
* participant writes report which requested ids resolved to members, gated the same way.
* 7. `node scripts/patch-wwebjs-block.js --best-effort` when present, restoring block and
* unblock after WhatsApp Web removed the contact resolver they used.
- * 8. `node scripts/patch-baileys-appstate.js --best-effort` when present, the app-state resync
+ * 8. `node scripts/patch-wwebjs-group-description.js --best-effort` when present, realigning the
+ * group-description job call with the options object the page now takes, gated the same way.
+ * 9. `node scripts/patch-baileys-appstate.js --best-effort` when present, the app-state resync
* bound, gated the same way.
- * 9. `node scripts/patch-baileys-newsletter-create.js --best-effort` when present, the
- * newsletter-create parse fix. Steps 7-8 are the Baileys patches, so a Baileys-only install
- * runs those and skips 2-6.
+ * 10. `node scripts/patch-baileys-newsletter-create.js --best-effort` when present, the
+ * newsletter-create parse fix. Steps 9-10 are the Baileys patches, so a Baileys-only install
+ * runs those and skips 2-8.
*
* Structured like scripts/patch-wwebjs-201832.js: pure planning + injectable spawn, so the spec
* (scripts/postinstall.spec.js, node:test) exercises every branch without a real npm run.
@@ -127,6 +129,17 @@ function planSteps(root, env = process.env) {
options: { stdio: 'inherit', cwd: root, env: cleanEnv },
});
}
+ const groupDescriptionPatcher = path.join(root, 'scripts', 'patch-wwebjs-group-description.js');
+ if (fs.existsSync(groupDescriptionPatcher)) {
+ steps.push({
+ name:
+ 'whatsapp-web.js group description job signature ' +
+ '(scripts/patch-wwebjs-group-description.js --best-effort)',
+ command: process.execPath,
+ args: [groupDescriptionPatcher, '--best-effort'],
+ options: { stdio: 'inherit', cwd: root, env: cleanEnv },
+ });
+ }
const baileysAppStatePatcher = path.join(root, 'scripts', 'patch-baileys-appstate.js');
if (fs.existsSync(baileysAppStatePatcher)) {
steps.push({
diff --git a/src/engine/docs-29-counts.spec.ts b/src/engine/docs-29-counts.spec.ts
index 50642cd2a..8f148c5b8 100644
--- a/src/engine/docs-29-counts.spec.ts
+++ b/src/engine/docs-29-counts.spec.ts
@@ -150,9 +150,12 @@ describe('docs/29 counts match the capability matrix', () => {
wrong.push(`not-available span: 29.8 says ${spanning[1]}, 29.4 says ${across[1]}`);
// 29.8's wwjs patch-dependency count must match the βœ…πŸ”§βΏ marks 29.4 actually carries. πŸ”§βΆ is the
- // one baileys row-level mark, so it is excluded from the wwjs figure.
+ // one baileys row-level mark, so it is excluded from the wwjs figure. The class spans every
+ // superscript a patcher can carry rather than the ones that happen to be row-marked today: a
+ // narrower class makes a NEW mark invisible here, so adding a patcher and marking its row would
+ // read as drift in the claim rather than agreement.
const contract = section(/^## 29\.4 /m, /^## 29\.5 /m);
- const marks = [...contract.matchAll(/βœ…πŸ”§([¹²³⁴⁡⁢⁷])/g)].map(m => m[1]);
+ const marks = [...contract.matchAll(/βœ…πŸ”§([¹²³⁴⁡⁢⁷⁸⁹])/g)].map(m => m[1]);
const wwjsMarks = marks.filter(m => m !== '⁢').length;
const claimed = doc.match(/\*\*(\d+) wwjs cells carry an explicit patch dependency\*\*/);
if (!claimed) wrong.push('patch dependency count: phrasing no longer found');
diff --git a/src/engine/engine-capability-matrix.ts b/src/engine/engine-capability-matrix.ts
index ed7d2e3e4..8b3dc93b9 100644
--- a/src/engine/engine-capability-matrix.ts
+++ b/src/engine/engine-capability-matrix.ts
@@ -332,7 +332,7 @@ export const CURATED_CAPABILITY_EXCEPTIONS: Record<string, MethodCapability> = {
wwjs: { status: 'supported' },
baileys: { status: 'supported' },
evidence:
- 'wwjs GroupChat.setDescription(description) β†’ boolean (index.d.ts:1984; false β†’ adapter throws EngineRefusedError); baileys groupUpdateDescription(jid, description?) (Socket/groups.d.ts:21)',
+ "wwjs GroupChat.setDescription(description) β†’ boolean (index.d.ts:1984; false β†’ adapter throws EngineRefusedError) β€” depends on πŸ”§βΉ (scripts/patch-wwebjs-group-description.js): stock 1.34.7 calls the page's WAWebGroupModifyInfoJob.setGroupDescription positionally, but that job now takes a single options object {desc, groupWid, newDescId, prevDescId}, so widToGroupJid reads an undefined Wid and throws inside the page, reaching the caller as a bare 500. setGroupSubject in the same module is still positional and is unaffected. Patched call measured live on wwjs 1.34.7: set reads back, empty string clears. baileys groupUpdateDescription(jid, description?) (Socket/groups.d.ts:21)",
},
setGroupEphemeral: {
wwjs: { status: 'not-available', rootCause: 'library-limitation' },