Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(changelog): record the release-workflow fix and the two behaviour corrections
Yudhi Armyndharisac4086a7b8c0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 846dc0640..17c0cd918 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Baileys group metadata now uses the phone-dialect twins the payload already carries (`ownerPn`, `participants[].phoneNumber`). Reading only the LID left `owner` and `participants[].id` as `<lid>@lid`, made `number` the LID digits presented as a phone number, and reported `isAdmin: false` for groups the account actually administers — ids that then failed to join against the `@c.us` the same session's contacts and message webhooks emit for the same person. It was only correct once the lid→phone mapping had been learned; the twin is available immediately. Where WhatsApp withholds the twin, as it does for non-contacts, the previous behaviour stands.-- On the Baileys engine, `isBlocked` on a contact read is now the account's real blocklist state rather than a literal `false`. Nothing derived it, while the same session's `/contacts/blocked` endpoint returned the real ids — so automation that skips blocked contacts before sending messaged people the account had explicitly blocked. A blocklist query that fails leaves the field at its default and logs a warning rather than failing the contact read or selling a transport failure as "nobody is blocked". `isMyContact` is unchanged: Baileys has no addressbook signal to derive it from, and inventing one would repeat the mistake.+- On the Baileys engine, `isBlocked` on a contact read is now the account's real blocklist state rather than a literal `false`. Nothing derived it, while the same session's `/contacts/blocked` endpoint returned the real ids — so automation that skips blocked contacts before sending messaged people the account had explicitly blocked. A blocklist query that fails leaves the field at its default and logs a warning rather than failing the contact read or selling a transport failure as "nobody is blocked". `isMyContact` is unchanged: Baileys has no addressbook signal to derive it from, and inventing one would repeat the mistake. The blocklist answer is memoised when it ARRIVES rather than when the query started — stamping the start wrote an already-expired memo for any query slower than the window, so contact reads, which used to come out of the in-memory store, paid the engine deadline again per read on exactly the slow links the memo was added for — and one in-flight query is now shared by every caller waiting on it.- Five whatsapp-web.js chat operations — mark-as-read, clear, archive, mark-unread and delete — no longer report a dead browser as a refusal. Each caught every error and resolved `false`, so the caller got `200 {"success": false}` ("WhatsApp declined a valid request") while the session's page was actually dead, and retried against it instead of receiving the documented 503. The early death signal was lost too, so the session kept reporting READY until the slower watchdog noticed. They now split transport failure out into `EngineTransportError` and report it, exactly as `getChats` and the other sibling reads in the same adapter already did. An ordinary page-side refusal still resolves `false`, unchanged.@@ -52,12 +52,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- The three group-picture routes now refuse an id that does not name a group. They reuse the account's own profile-picture primitives, and Baileys omits the `target` attribute whenever the jid is the account's own — so `PUT` or `DELETE /sessions/:id/groups/<own-jid>/picture` replaced or permanently deleted the WhatsApp account's own avatar and answered `{success: true}`, while whatsapp-web.js refused the same input with a 404. Both engines now reject it with a 400 before the id reaches either adapter. The published responses were corrected to match: the 404 no longer claims the 1:1-chat case the 400 now owns, and `PUT` documents the new 400 alongside its existing ones.-- `GET /sessions/:sessionId/messages` and the MCP `MessageList` tool now bound the inline media they return, via `MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES` (8 MiB of encoded base64 by default). The row count was clamped to 1..100, but a row is not a bounded object: each carries its base64 in `metadata.media.data`, so a hundred media rows serialised to well over a hundred megabytes, and a large enough page pushed `JSON.stringify` past its ceiling and failed the read outright — permanently for the dashboard, which requests the maximum page size with no way to ask for less. The budget is spent newest-first; past it a payload is replaced with the `{ omitted: true, sizeBytes }` marker the engine already emits for skipped inbound media, and remains fetchable from the per-message media route. In the dashboard a trimmed message shows the same 📎 Media placeholder it already uses for media the engine skipped on the way in, and `MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES` raises the budget for a deployment that would rather pay the bytes. The knob is checked at boot like its export-side sibling — `8MiB` would otherwise parse to 8 bytes and omit everything — and is forwarded by both compose files.+- `GET /sessions/:sessionId/messages` and the MCP `MessageList` tool now bound the inline media they return, via `MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES` (8 MiB of encoded base64 by default). The row count was clamped to 1..100, but a row is not a bounded object: each carries its base64 in `metadata.media.data`, so a hundred media rows serialised to well over a hundred megabytes, and a large enough page pushed `JSON.stringify` past its ceiling and failed the read outright — permanently for the dashboard, which requests the maximum page size with no way to ask for less. The budget is spent newest-first; past it a payload is replaced with the `{ omitted: true, sizeBytes }` marker the engine already emits for skipped inbound media, and remains fetchable from the per-message media route. In the dashboard a trimmed message shows the same 📎 Media placeholder it already uses for media the engine skipped on the way in, and `MESSAGE_LIST_INLINE_MEDIA_BUDGET_BYTES` raises the budget for a deployment that would rather pay the bytes. The knob is checked at boot like its export-side sibling — `8MiB` would otherwise parse to 8 bytes and omit everything — and is forwarded by both compose files. The newest payload is always let through even when it alone exceeds the budget: omitting it left a single large photo or video permanently unreadable through this route, since the dashboard thread has no other media source and caches with `staleTime: Infinity`. A budget of 0 still means "do not inline" and grants no allowance.- Bulk send now caps its rendered result at `TEMPLATE_RENDER_MAX_CHARS` (default 64 KiB), the same limit the single-send template path already enforced. `content.text` is length-validated before substitution, so caller-supplied variables inflated each item without bound while the request body stayed far below the in-flight body budget — a few hundred KiB of variables became hundreds of megabytes of heap per item, then went to the engine and the `messages.body` column. An over-cap render now fails that item with a message naming the limit, exactly as a pacing refusal does, rather than being truncated silently or sent.- The published image's drop from root to the `openwa` user is now verified in CI. The Dockerfile carries no `USER` directive by design — `docker-entrypoint.sh` starts as root to fix named-volume ownership and then runs `exec gosu openwa` — and `scripts/smoke-test-non-root.sh` was the only check of that drop, but no workflow ran it: its sole appearance in `ci.yml` was inside a comment. A change leaving the Node process on uid 0 passed lint, every test job, the multi-arch build and the image scan, and was promoted to `latest`. The Docker job now loads a single-arch image from the cache the multi-arch build already populated and runs the smoke test against it. The release path checks it too, since that is the path that promotes to `latest`.+- The release workflow's non-root check can now run at all. The job invoking `scripts/smoke-test-non-root.sh` had no `actions/checkout`, so the script was absent from the workspace and the step exited 127 — failing every tag build and blocking the only path that publishes `latest`, rather than guarding it. A gate now binds the precondition across every workflow: a job that runs a repo-relative command must check the repo out.+- The dashboard's dependency tree is now audited on both the PR and the tag path. It went unscanned by every job: `npm audit` ran against the root tree only, and the image scan sees OS packages and the built bundle rather than the npm graph behind it — so a HIGH advisory in a dependency that reaches an operator's browser could ride a release undetected. Two were present at this baseline: `socket.io-parser` (bundled into `dashboard/dist` via `socket.io-client`) and `brace-expansion` (dev-only, via ESLint), the latter pinned to a vulnerable version by an override that had not been bumped. Both are now overridden to patched releases.- `.env.example` shipped five keys the Infrastructure dashboard owns — `POSTGRES_BUILTIN`, `DATABASE_SSL`, `DATABASE_SSL_REJECT_UNAUTHORIZED`, `REDIS_BUILTIN` and `MINIO_BUILTIN` — uncommented, so an operator who followed the documented `cp .env.example .env` pinned them: the dashboard control still saved and reported success while the running value never changed, most consequentially leaving a Postgres connection unencrypted after the operator enabled SSL. The file's own header already promised a gate against this, but that gate only reached keys docker-compose forwards blank; it now covers every key the dashboard writes. `.env.minimal`, the other documented starting point, no longer pins the three built-in datastore toggles either; its deliberate development pins are left alone.