Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(wwjs): qualify a bare participant id on the membership-request writes

Yudhi Armyndharisc738af12a8da
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6f6ff82f..b07668a1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `check:sdk-coverage` no longer passes when a client drops a route entirely: a wildcard the client built for a path parameter — `contacts/${contactId}` — was read as a one-builder family and stood in for every concrete sibling under it, so removing `contacts/blocked` from a client left the gate green. A wildcard now counts as a family only where the contract publishes no route of that shape.
- The Go SDK no longer approves or rejects every pending join request when handed an empty participant list: `omitempty` dropped the empty slice, so `[]string{}` reached the gateway as the bodyless "act on every request" rather than the `400` the other four clients receive. A nil slice still means every request.
+- Approving or rejecting a join request by bare phone number works on the whatsapp-web.js engine instead of answering `500`: the participant guard accepts a bare number and the three other participant writes qualify it, but these two routes handed it to the engine unqualified, so it reached the page as an unaddressable id. The same request already worked on Baileys. Refs #1220.
- The chart's optional ServiceMonitor now selects on a new `openwa.io/scrape-target` label, so it scrapes one target per pod instead of two; series previously collected through the headless target stop appearing, so check anything keyed on the `service` label.
- The Helm chart's new startup probe stops the kubelet killing a pod that is still booting, allowing 295s (`periodSeconds: 5`, `failureThreshold: 60`) where the liveness settings allowed 50. It fires immediately, so a fast boot goes live sooner than before, not later — and it is not limited to auto-start, since the database connect retry alone can consume 30 of the old 50 seconds.
- A Helm upgrade that changes only `env` or `secretEnv` now restarts the pod through ConfigMap and Secret checksums, so the new configuration reaches the running container. With `existingSecret` set the chart renders no Secret, so that path still needs `kubectl rollout restart`; `values.yaml` notes what publishing the Secret checksum as a pod annotation means.
diff --git a/src/engine/adapters/membership-requests.spec.ts b/src/engine/adapters/membership-requests.spec.ts
index 705f437f6..98b3a99e2 100644
--- a/src/engine/adapters/membership-requests.spec.ts
+++ b/src/engine/adapters/membership-requests.spec.ts
@@ -123,6 +123,26 @@ describe('WwebjsGroups membership requests', () => {
]);
});
+ it.each([
+ ['approve', 'approveGroupMembershipRequests' as const],
+ ['reject', 'rejectGroupMembershipRequests' as const],
+ ])('%ss a bare phone number after qualifying it, like every other participant write', async (_action, method) => {
+ // GroupService.assertAddressableParticipants blesses a bare number, and the three other
+ // participant paths in this file qualify it before the engine sees it. Unqualified it reaches
+ // the page's `requesterIds.map(createWid)` (Injected/Utils.js:1540-1542), which upstream never
+ // does itself — Client.js appends '@c.us' before its own createWid calls — so the caller got an
+ // undiagnosable 500 on whatsapp-web.js for input that succeeds on Baileys.
+ const { groups, client } = makeWwebjsGroups();
+ client[method].mockResolvedValue([{ requesterId: '[email protected]', message: 'done' }]);
+
+ await groups[method]('[email protected]', ['628123456789', '[email protected]']);
+
+ expect(client[method]).toHaveBeenCalledWith('[email protected]', {
+ requesterIds: ['[email protected]', '[email protected]'],
+ sleep: [250, 500],
+ });
+ });
+
it('reports the code-less ServerStatusCodeError entry as a FAILURE, not a success', async () => {
// The page util's non-success RPC branch pushes {requesterId, message: 'ServerStatusCodeError'}
// with NO error code (Injected/Utils.js:1637-1648) — reading "no error field" as success would
diff --git a/src/engine/adapters/wwebjs-groups.ts b/src/engine/adapters/wwebjs-groups.ts
index 0e41a213e..84f9192f0 100644
--- a/src/engine/adapters/wwebjs-groups.ts
+++ b/src/engine/adapters/wwebjs-groups.ts
@@ -606,7 +606,12 @@ export class WwebjsGroups {
): Promise<ParticipantOperationResult[]> {
this.host.ensureReady();
const raw = await this.client()[op](groupId, {
- requesterIds: participants ?? null,
+ // Qualified like every other participant write in this file: the service blesses a bare phone
+ // number, and the page maps requesterIds straight through `createWid` (Injected/Utils.js) —
+ // which upstream itself never hands a bare number, appending '@c.us' first. Unqualified it
+ // threw inside the minified bundle and the caller got an undiagnosable 500, while the same
+ // input succeeded on Baileys. `null` still means every pending request.
+ requesterIds: participants?.map(toParticipantWid) ?? null,
sleep: [250, 500],
});
// {requesterId, error?, message} per requester; requesterId is a page-context value that can