Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1290 from batuhannarci/updateMultipleWebhookHandl…
Browse files Browse the repository at this point in the history
…ersError

Update multiple webhook handlers error
  • Loading branch information
lizkenyon authored Mar 21, 2024
2 parents 9b80da2 + 5b36cf3 commit 84ddb5c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changeset/rich-falcons-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
8 changes: 6 additions & 2 deletions packages/shopify-api/lib/webhooks/__tests__/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ describe('shopify.webhooks.addHandlers', () => {
return shopify.webhooks.addHandlers({
PRODUCTS_CREATE: [EVENT_BRIDGE_HANDLER, EVENT_BRIDGE_HANDLER],
});
}).toThrow('Can only add multiple handlers when deliveryMethod is Http.');
}).toThrow(
'Can only add multiple handlers for a topic when deliveryMethod is Http. Please be sure that you used addHandler method once after creating ShopifyApi instance in your app.',
);
});

it('fails if pubsub handlers point to the same location', async () => {
Expand All @@ -79,7 +81,9 @@ describe('shopify.webhooks.addHandlers', () => {
return shopify.webhooks.addHandlers({
PRODUCTS_CREATE: [PUB_SUB_HANDLER, PUB_SUB_HANDLER],
});
}).toThrow('Can only add multiple handlers when deliveryMethod is Http.');
}).toThrow(
'Can only add multiple handlers for a topic when deliveryMethod is Http. Please be sure that you used addHandler method once after creating ShopifyApi instance in your app.',
);
});

it('adds handler with lowercase/slash-period format to the webhook registry', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/shopify-api/lib/webhooks/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function mergeOrAddHandler(
break;
} else {
throw new InvalidDeliveryMethodError(
`Can only add multiple handlers when deliveryMethod is Http. Invalid handler: ${JSON.stringify(
`Can only add multiple handlers for a topic when deliveryMethod is Http. Please be sure that you used addHandler method once after creating ShopifyApi instance in your app. Invalid handler: ${JSON.stringify(
handler,
)}`,
);
Expand Down

0 comments on commit 84ddb5c

Please sign in to comment.