Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(ingress): pin the blank-header dedup key to the body, not to freshness

Yudhi Armyndharis280fec2b27e3
diff --git a/src/modules/integration/ingress.service.spec.ts b/src/modules/integration/ingress.service.spec.ts
index 3b09b5163..e21913f91 100644
--- a/src/modules/integration/ingress.service.spec.ts
+++ b/src/modules/integration/ingress.service.spec.ts
@@ -555,6 +555,13 @@ describe('dedupOn: body (a provider that rotates its delivery id on retry)', ()
// The ids differ, which is the whole point: a blank header must not collapse two bodies onto one
// dedup row. (A fresh `deps()` always enqueues, so asserting the call count would prove nothing.)
expect((second.enqueue.mock.calls[0] as [unknown, string])[1]).not.toBe(firstId);
+
+ // And the fallback is the BODY hash, not a fresh value per delivery: the same bytes must key the
+ // same row, or a provider's retry of a blank-header delivery is processed a second time. An id
+ // minted per call would satisfy the inequality above while breaking what dedup exists for.
+ const repeat = deps();
+ await new IngressService(repeat).handle({ ...req, headers: { 'x-delivery': '' }, rawBody: '{"n":1}' });
+ expect((repeat.enqueue.mock.calls[0] as [unknown, string])[1]).toBe(firstId);
});
});