Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(openapi): publish a webhook's filters as nullable

Yudhi Armyndharis2a0024dcd58c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e7fa25a40..23c0d27a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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.
- A burst of inbound media on the whatsapp-web.js engine no longer loses the media of everything past the eighth, which the Baileys repair in this release left in place on the other engine: its download queue was capped at its active slots too, making admission a constant 8 whatever the batch size. A burst now parks rather than shedding, and only the download waits — a text message never enters the limiter. The wait for a slot is bounded by `MEDIA_DOWNLOAD_TIMEOUT_MS`, so a burst queued behind a hung page still emits its messages without media rather than waiting on a slot that never frees.
+- A webhook's `filters` is published as nullable, the sibling of the `lastTriggeredAt` repair in this release: the field is stored as `null` for every webhook created without filters and the description offers `null` as an input, but the schema declared neither, so a client generated from the contract rejected a value the route both sends and accepts. An invariant now fails when any property documented as carrying `null` does not publish it.
- 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/openapi.json b/openapi.json
index 231343f81..ccac0da13 100644
--- a/openapi.json
+++ b/openapi.json
@@ -10283,7 +10283,8 @@
"value": "invoice"
}
]
- }
+ },
+ "nullable": true
},
"retryCount": {
"type": "number",
@@ -10333,7 +10334,8 @@
"value": "invoice"
}
]
- }
+ },
+ "nullable": true
},
"active": {
"type": "boolean"
@@ -10433,7 +10435,8 @@
"value": "invoice"
}
]
- }
+ },
+ "nullable": true
},
"active": {
"type": "boolean",
diff --git a/src/config/openapi-contract.spec.ts b/src/config/openapi-contract.spec.ts
index cecb12da2..9b971e348 100644
--- a/src/config/openapi-contract.spec.ts
+++ b/src/config/openapi-contract.spec.ts
@@ -139,6 +139,34 @@ describe('openapi.json structural invariants', () => {
expect(bare).toEqual([]);
});
+ it('declares nullability on every property whose description offers null', () => {
+ const doc = snapshot();
+ // A property documented as carrying null must publish it, or a client generated from the
+ // contract rejects a value the gateway both sends and accepts. `lastTriggeredAt` was fixed that
+ // way; `filters` — stored as `dto.filters ?? null` for every webhook created without one — was
+ // the sibling left behind, which is why this is an invariant rather than three more spellings.
+ //
+ // A container satisfies it through its members: `pictures` is never null, but its values are,
+ // and it declares that on additionalProperties.
+ const scanned: string[] = [];
+ const undeclared: string[] = [];
+
+ type Spec = { description?: string; nullable?: boolean; items?: Spec; additionalProperties?: Spec | boolean };
+ for (const [name, schema] of Object.entries(doc.components?.schemas ?? {})) {
+ const properties = (schema as { properties?: Record<string, Spec> }).properties ?? {};
+ for (const [property, spec] of Object.entries(properties)) {
+ if (!/\bnull\b/i.test(spec.description ?? '')) continue;
+ scanned.push(`${name}.${property}`);
+ const member = typeof spec.additionalProperties === 'object' ? spec.additionalProperties : spec.items;
+ if (spec.nullable !== true && member?.nullable !== true) undeclared.push(`${name}.${property}`);
+ }
+ }
+
+ // Guard the selector: a description reworded away from the word would scan nothing and pass.
+ expect(scanned.length).toBeGreaterThan(15);
+ expect(undeclared).toEqual([]);
+ });
+
it('gives each route exactly one path key, whatever its parameters are named', () => {
const doc = snapshot();
// A path template variable is positional: `/x/{id}` and `/x/{sessionId}` are the same URL. Two
diff --git a/src/modules/webhook/dto/webhook.dto.ts b/src/modules/webhook/dto/webhook.dto.ts
index 2aea7de5a..f38e8fa36 100644
--- a/src/modules/webhook/dto/webhook.dto.ts
+++ b/src/modules/webhook/dto/webhook.dto.ts
@@ -105,7 +105,11 @@ export class CreateWebhookDto {
@IsHeaderMap()
headers?: Record<string, string>;
- @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE })
+ // `nullable` spelled out for the same reason lastTriggeredAt spells out its type: the field is
+ // STORED as null whenever a webhook is created without filters (`dto.filters ?? null`), and the
+ // description offers null as an input, so a schema without it rejects a value the route both
+ // sends and accepts.
+ @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE, nullable: true })
@IsOptional()
@IsValidWebhookFilters()
filters?: WebhookFilters | null;
@@ -154,7 +158,11 @@ export class UpdateWebhookDto {
@IsHeaderMap()
headers?: Record<string, string>;
- @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE })
+ // `nullable` spelled out for the same reason lastTriggeredAt spells out its type: the field is
+ // STORED as null whenever a webhook is created without filters (`dto.filters ?? null`), and the
+ // description offers null as an input, so a schema without it rejects a value the route both
+ // sends and accepts.
+ @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE, nullable: true })
@IsOptional()
@IsValidWebhookFilters()
filters?: WebhookFilters | null;
@@ -206,7 +214,11 @@ export class WebhookResponseDto {
events!: string[];
@Expose()
- @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE })
+ // `nullable` spelled out for the same reason lastTriggeredAt spells out its type: the field is
+ // STORED as null whenever a webhook is created without filters (`dto.filters ?? null`), and the
+ // description offers null as an input, so a schema without it rejects a value the route both
+ // sends and accepts.
+ @ApiPropertyOptional({ description: FILTERS_API_DESCRIPTION, example: FILTERS_API_EXAMPLE, nullable: true })
filters?: WebhookFilters | null;
@Expose()