Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(changelog): record the metrics-table fix and extend two entries
Yudhi Armyndharis33477ee5e9b1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8e0c8d1e4..846dc0640 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- An ingress route whose manifest omits `maxBodyBytes` is no longer unbounded by its own cap. The check compared a byte length against `undefined`, which is always false, so the per-route 413 the published contract promises was silently inert — and every accepted delivery is persisted with the body stored twice and carried into the queue, turning one forgotten manifest field into a write amplifier with no load-time error and no runtime signal. A route with no usable value now falls back to the process-wide body limit (what it was already bounded by in practice, so nothing accepted today starts failing) and the gap is logged once per route instead of passing in silence.-- A `message:sending` plugin handler that returns a payload without a usable `input` no longer turns every outbound send on that session into a 500. The gate read `.input` off the hook chain's reply unchecked, so a malformed envelope handed `undefined` to each caller — or threw inside the gate for a `null` — with nothing in the error naming a plugin. The send is now refused with a message that names the hook, and refused rather than sent: this is a moderation chokepoint, and a handler whose reply cannot be read may have been redacting something. A chain that replies with nothing at all is unchanged and keeps the caller's own input.+- A `message:sending` plugin handler that returns a payload without a usable `input` no longer turns every outbound send on that session into a 500. The gate read `.input` off the hook chain's reply unchecked, so a malformed envelope handed `undefined` to each caller — or threw inside the gate for a `null` — with nothing in the error naming a plugin. The send is now refused with a message that names the hook, and refused rather than sent: this is a moderation chokepoint, and a handler whose reply cannot be read may have been redacting something. A chain that replies with nothing at all is unchanged and keeps the caller's own input. The refusal is also logged with the session and call site, because the 400 reaches the API caller while the person who can fix the plugin sees only that sends stopped.- The `openwa_sessions_restricted` gauge now follows a restriction that lapses on its own. It was republished only when a restriction was recorded or cleared, and an expiry is neither — so after a reachout timelock passed its stated end, the gauge kept reporting the pre-expiry count while every read path already reported the session as unrestricted, leaving an alert on `> 0` firing indefinitely and disagreeing with `GET /api/sessions`.@@ -46,9 +46,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `GET /api/metrics` no longer fails the whole scrape when the data database is unreachable. `render()` awaited a stats query unguarded, so a statement timeout, pool exhaustion, a `SQLITE_BUSY` under load or a genuine outage answered every scrape with a 500 once the 30-second stats memo lapsed — costing Prometheus the process, HTTP and webhook series too, and making `up` conflate a dead process with an unreachable database, during the exact incident the endpoint exists to describe. The database-derived series are now omitted rather than reported as zero (a zero would fire an alert claiming every session had dropped), and a new `openwa_stats_available` gauge says which of the two happened.+- The metrics reference now lists every series `GET /api/metrics` emits. It introduced its table as "the complete set — nothing else is emitted" while naming 10 of 15, so the webhook-failure, session-reconnect, restricted-session and pacing-refusal counters an operator would alert on were absent from the document they alert from. A gate compares the table against the renderer, and the text now says which series are conditional, since omitting one is not the same as reporting zero.+- An authorization denial now records WHICH credential was denied. Both post-authentication 403s — an insufficient role, and a session-scoped key on a route that forbids one — threw before the resolved key was stamped into the request context, so every such audit row carried `apiKeyId` and `apiKeyName` as null. Behind NAT or a reverse proxy without `TRUSTED_PROXIES` the recorded IP is common to every tenant, leaving an operator able to see that a key had been denied but not which one to revoke. The same stamp was added to the queue-dashboard mount, which has the same shape. A denial that happens before any key resolves is unchanged: the IP really is all there is.-- 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 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.