Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(openapi): correct four schemas that publish values the API cannot emit

Yudhi Armyndharis390beb26b3d2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63f1c73a0..de59203c4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- **Four response schemas published values the API cannot emit** — search results documented `direction` as `inbound`/`outbound` while every hit carries `incoming`/`outgoing`, so a client validating against the contract would have rejected all of them; audit entries documented `warning` where the code writes `warn`; the search example named a provider id that does not exist; and the data export omitted `skippedTables` and `omittedInlineMedia` — the two fields that say the archive is truncated. Group detail also advertised a `participantsCount` and an `isAdmin` that only the group LIST returns.
- **The published image now actually carries the app-state resync fix** — the patcher that bounds the loop was wired into the install hook but never added to the two hand-written lists in the Dockerfile, so it was absent from the production stage, the hook's existence check skipped it without a word, and every image shipped unpatched. It is copied and run fatally now, and a derived check fails the build if a patcher is ever added to one list and not the other.
- **A channel refusal answers `403` again, not a bare `500`** — narrowing the refusal classifier in the same release fixed the IQ error channel and silently de-classified the other one: WhatsApp's `w:mex` surface reports a refusal as a GraphQL error inside a _successful_ IQ, so it never carries the numeric code the classifier now reads, and deleting or muting a channel the account does not own regressed from `403` to an opaque `500`. The two error channels are decoded separately now; a dead socket and an unanswered query still do not read as refusals.
- **A profile picture lookup that WhatsApp never answered no longer reads as "this contact has no picture"** — the route answered `200` with `url: null` after a silent minute, which is the same answer a contact without a picture gives, so a caller had no way to tell them apart; it now answers `503`. Passing the engine's own timeout would not have been enough on its own, because the resulting error landed in the catch that produces that same `null`. The batch lookup is unchanged: a per-id failure there is documented as `null` and stays that way.
@@ -32,8 +33,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **A benign whatsapp-web.js rejection no longer reads like a crash** — the same un-awaited `framenavigated` re-injection that already logs at `WARN` when the page goes away was logged at `ERROR` in its other shape, where the navigation lands before WhatsApp Web has defined its module registry; it appears at the first boot after the pinned WhatsApp Web build moves under a warm profile, and the session reaches ready unaided.
- **A slow whatsapp-web.js attach is no longer mistaken for a dead one and reloaded out from under itself** — the event-bridge self-heal could fire on the first reconcile tick, two seconds after `authenticated`, but whatsapp-web.js clears `eventsAttached` in its constructor and sets it only once `attachEventListeners` resolves, with `LoadUtils`, a poll of up to thirty seconds for `window.WWebJS`, `ClientInfo` and `InterfaceController` in between, so a false flag is the ordinary reading for most of a minute on a loaded host. The reload then navigated the page out from under the injection still running on it, whose re-entry died at `getWWebVersion` before re-exposing any of the bridge, and the one-shot guard blocked a second attempt, so the session rode out the readiness deadline and was marked failed — credentials kept, but no way back without a restart. The reload now waits out the upstream attach budget first, which still leaves it half the deadline to reinject when one is genuinely warranted.
-### Fixed
-
- **A data export now reports the media it had to leave behind** — an over-budget attachment is replaced with the same omitted marker that media skipped on the way in gets, so a truncated backup was indistinguishable from a complete one both on inspection and on restore; the response now carries `omittedInlineMedia` alongside `skippedTables`, and the dashboard warns after a download that dropped anything.
- **A node that has observed the loss of its session lease no longer writes `FAILED` for that session** — engine callbacks were fenced only by a local liveness check, so between a heartbeat detecting the loss and the teardown it schedules, a dying generation could park a row a peer already owned in `FAILED`, which is excluded from both the boot reset and the takeover sweep by design and so left the session outside every automatic recovery path on every node until an operator restarted it by hand. The fence engages from the heartbeat tick that detects the loss, not from the moment the lease lapses, so a window remains.
- **Thirteen settings that did nothing under Docker now take effect** — Compose forwards environment explicitly and has no `env_file`, so `BAILEYS_MARK_ONLINE_ON_CONNECT`, `BAILEYS_SYNC_FULL_HISTORY`, `WEBHOOK_CONTACT_DETAILS`, `ALLOW_UNSIGNED_INGRESS`, `STORE_EPHEMERAL_MESSAGES`, `RESOLVE_LID_TO_PHONE`, `SIMULATE_TYPING`, `MCP_ENABLED`, `SEARCH_ENABLED`, `SERVE_DASHBOARD`, `CACHE_ENABLED`, `DATABASE_LOGGING` and `MAIN_DATABASE_SYNCHRONIZE` never reached the container however the operator's `.env` was written — the MCP server could not be enabled at all, `SEARCH_ENABLED=false` did not disable the search route it documents, and `BAILEYS_MARK_ONLINE_ON_CONNECT` left the paired phone's notifications suppressed for as long as the gateway stayed connected.
diff --git a/docs/05-database-design.md b/docs/05-database-design.md
index 3cf2c7fb4..b08b12166 100644
--- a/docs/05-database-design.md
+++ b/docs/05-database-design.md
@@ -577,7 +577,7 @@ CREATE INDEX "IDX_c69efb19bf127c97e6740ad530" ON audit_logs("createdAt");
`api_key_updated`, `api_key_used`, `api_key_revoked`, `api_key_deleted`, `api_key_auth_failed`), session
lifecycle (`session_created`, `session_started`, `session_stopped`, `session_force_killed`,
`session_logged_out`, `session_deleted`, `session_qr_generated`, `session_connected`,
-`session_disconnected`), WhatsApp-imposed account restrictions (`session_restricted`,
+`session_disconnected`, `session_config_updated`), WhatsApp-imposed account restrictions (`session_restricted`,
`session_restriction_lifted`), messages
(`message_sent`, `message_failed`), send-pacing enforcement (`send_pacing_blocked`, sampled to at
most one row per session per minute; `send_breaker_tripped`, never sampled), webhooks (`webhook_created`, `webhook_deleted`,
diff --git a/openapi.json b/openapi.json
index 04a51d734..c12e050f9 100644
--- a/openapi.json
+++ b/openapi.json
@@ -8115,7 +8115,7 @@
"type": "string",
"enum": [
"info",
- "warning",
+ "warn",
"error"
],
"example": "info"
@@ -11143,6 +11143,25 @@
"automationRules"
]
},
+ "OmittedInlineMediaDto": {
+ "type": "object",
+ "properties": {
+ "messages": {
+ "type": "number",
+ "description": "Message attachments replaced with an omitted marker.",
+ "example": 0
+ },
+ "messageBatches": {
+ "type": "number",
+ "description": "Batch attachments replaced with an omitted marker.",
+ "example": 0
+ }
+ },
+ "required": [
+ "messages",
+ "messageBatches"
+ ]
+ },
"InfraExportDataResponseDto": {
"type": "object",
"properties": {
@@ -11166,13 +11185,31 @@
"$ref": "#/components/schemas/TableCountsDto"
}
]
+ },
+ "skippedTables": {
+ "description": "Tables the running database does not have, which were skipped rather than exported. A restore from this file will not repopulate them.",
+ "example": [],
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "omittedInlineMedia": {
+ "description": "Inline media dropped for exceeding the export budget. Non-zero means the archive is TRUNCATED — the rows are present but their attachments are replaced with an omitted marker.",
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/OmittedInlineMediaDto"
+ }
+ ]
}
},
"required": [
"exportedAt",
"dataDbType",
"tables",
- "counts"
+ "counts",
+ "skippedTables",
+ "omittedInlineMedia"
]
},
"InfraImportDataResponseDto": {
@@ -11576,16 +11613,6 @@
"description": "Group subject.",
"example": "Engineering"
},
- "participantsCount": {
- "type": "number",
- "description": "Member count, when the engine reports it.",
- "example": 42
- },
- "isAdmin": {
- "type": "boolean",
- "description": "Whether this account is an admin of the group.",
- "example": true
- },
"linkedParentJID": {
"type": "string",
"nullable": true,
@@ -13551,10 +13578,10 @@
"direction": {
"type": "string",
"enum": [
- "inbound",
- "outbound"
+ "incoming",
+ "outgoing"
],
- "example": "inbound"
+ "example": "incoming"
},
"from": {
"type": "string",
@@ -13602,7 +13629,7 @@
"provider": {
"type": "string",
"description": "Which provider answered.",
- "example": "builtin-db"
+ "example": "builtin-fts"
}
},
"required": [
diff --git a/src/modules/audit/dto/audit-response.dto.ts b/src/modules/audit/dto/audit-response.dto.ts
index f4b362ffd..344ecd342 100644
--- a/src/modules/audit/dto/audit-response.dto.ts
+++ b/src/modules/audit/dto/audit-response.dto.ts
@@ -12,7 +12,7 @@ export class AuditLogDto {
@ApiProperty({ description: 'What happened.', example: 'session.create' })
action!: string;
- @ApiProperty({ enum: ['info', 'warning', 'error'], example: 'info' })
+ @ApiProperty({ enum: ['info', 'warn', 'error'], example: 'info' })
severity!: string;
@ApiProperty({ type: String, nullable: true, description: 'Null for an unauthenticated or system action.' })
diff --git a/src/modules/group/dto/group-response.dto.ts b/src/modules/group/dto/group-response.dto.ts
index 4dc64bdcc..97c4bdfa1 100644
--- a/src/modules/group/dto/group-response.dto.ts
+++ b/src/modules/group/dto/group-response.dto.ts
@@ -48,7 +48,26 @@ export class GroupSummaryDto {
linkedParentJID?: string | null;
}
-export class GroupInfoDto extends GroupSummaryDto {
+/**
+ * Deliberately NOT extending GroupSummaryDto. The summary carries participantsCount and isAdmin,
+ * which the group LIST computes and this route does not send at all — advertising them here would
+ * offer a client an admin flag that is always undefined.
+ */
+export class GroupInfoDto {
+ @ApiProperty({ description: 'Group id.', example: '[email protected]' })
+ id!: string;
+
+ @ApiProperty({ description: 'Group subject.', example: 'Engineering' })
+ name!: string;
+
+ @ApiPropertyOptional({
+ type: String,
+ nullable: true,
+ description: 'JID of the parent community, or null when the group is standalone.',
+ example: null,
+ })
+ linkedParentJID?: string | null;
+
@ApiPropertyOptional({ description: 'Group description.', example: 'Release coordination' })
description?: string;
diff --git a/src/modules/infra/dto/infra-response.dto.ts b/src/modules/infra/dto/infra-response.dto.ts
index d0d2156ea..df1a5150e 100644
--- a/src/modules/infra/dto/infra-response.dto.ts
+++ b/src/modules/infra/dto/infra-response.dto.ts
@@ -407,6 +407,14 @@ export class TableCountsDto {
@ApiProperty({ example: 2 }) automationRules!: number;
}
+export class OmittedInlineMediaDto {
+ @ApiProperty({ description: 'Message attachments replaced with an omitted marker.', example: 0 })
+ messages!: number;
+
+ @ApiProperty({ description: 'Batch attachments replaced with an omitted marker.', example: 0 })
+ messageBatches!: number;
+}
+
export class InfraExportDataResponseDto {
@ApiProperty({ description: 'ISO-8601 timestamp the export was taken.', example: '2026-08-07T12:00:00.000Z' })
exportedAt!: string;
@@ -419,6 +427,23 @@ export class InfraExportDataResponseDto {
@ApiProperty({ type: TableCountsDto, description: 'Row counts, so a truncated restore is detectable.' })
counts!: TableCountsDto;
+
+ @ApiProperty({
+ type: [String],
+ description:
+ 'Tables the running database does not have, which were skipped rather than exported. A restore ' +
+ 'from this file will not repopulate them.',
+ example: [],
+ })
+ skippedTables!: string[];
+
+ @ApiProperty({
+ type: OmittedInlineMediaDto,
+ description:
+ 'Inline media dropped for exceeding the export budget. Non-zero means the archive is TRUNCATED — ' +
+ 'the rows are present but their attachments are replaced with an omitted marker.',
+ })
+ omittedInlineMedia!: OmittedInlineMediaDto;
}
export class InfraImportDataResponseDto {
diff --git a/src/modules/search/dto/search-response.dto.ts b/src/modules/search/dto/search-response.dto.ts
index a2eff1e05..cb327be3a 100644
--- a/src/modules/search/dto/search-response.dto.ts
+++ b/src/modules/search/dto/search-response.dto.ts
@@ -31,7 +31,7 @@ export class SearchHitDto {
timestamp!: number;
@ApiProperty({ example: 'text' }) type!: string;
- @ApiProperty({ enum: ['inbound', 'outbound'], example: 'inbound' }) direction!: string;
+ @ApiProperty({ enum: ['incoming', 'outgoing'], example: 'incoming' }) direction!: string;
@ApiProperty({ description: 'Sender id.', example: '[email protected]' })
from!: string;
@@ -50,6 +50,6 @@ export class SearchResultsResponseDto {
@ApiProperty({ description: 'How long the provider took, in milliseconds.', example: 12 })
tookMs!: number;
- @ApiProperty({ description: 'Which provider answered.', example: 'builtin-db' })
+ @ApiProperty({ description: 'Which provider answered.', example: 'builtin-fts' })
provider!: string;
}