diff --git a/backend/src/modules/webhooks/repository.ts b/backend/src/modules/webhooks/repository.ts index fc56cc6..fab0bc3 100644 --- a/backend/src/modules/webhooks/repository.ts +++ b/backend/src/modules/webhooks/repository.ts @@ -96,10 +96,12 @@ export async function findSubscriptionsForEvent( productId: string, eventType: WebhookEventType ): Promise { - // events is a string[] — $contains works for primitive arrays in memory provider - return subsCollection().findMany({ - filter: { userId, productId, active: true, events: { $contains: eventType } }, + // $contains generates CONTAINS() SQL (string match) in Cosmos, not ARRAY_CONTAINS(). + // Use findMany + post-filter for correct behavior across both providers. + const subs = await subsCollection().findMany({ + filter: { userId, productId, active: true }, }); + return subs.filter(s => s.events.includes(eventType)); } // ── Increment Failure Count ───────────────────────────────────