Skip to content

Commit

Permalink
Merge pull request #4150 from Shopify/explore-webhook-matching-stable-2
Browse files Browse the repository at this point in the history
[stable] Match webhooks by comparing relative and absolute paths
  • Loading branch information
isaacroldan authored Jul 3, 2024
2 parents 086af5e + 3f98e53 commit 822a80e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-bikes-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Fix an issue with webhooks being recreated during deploy
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ describe('ensureNonUuidManagedExtensionsIds: for extensions managed in the TOML'
const config = {
topic: 'orders/delete',
api_version: '2024-01',
uri: 'https://my-app.com/webhooks',
uri: '/webhooks',
include_fields: ['id'],
filter: 'id:*',
}
Expand All @@ -1172,7 +1172,8 @@ describe('ensureNonUuidManagedExtensionsIds: for extensions managed in the TOML'
title: 'Webhook Subscription',
type: 'WEBHOOK_SUBSCRIPTION',
activeVersion: {
config: JSON.stringify(config),
// use absolute path here to test that it matches both absolute and relative paths from the local config
config: JSON.stringify({...config, uri: 'https://my-app.com/webhooks'}),
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ function matchWebhooks(remoteSource: RemoteSource, extension: ExtensionInstance)
const remoteVersionConfig = remoteSource.activeVersion?.config
const remoteVersionConfigObj = remoteVersionConfig ? JSON.parse(remoteVersionConfig) : {}
const localConfig = extension.configuration as unknown as SingleWebhookSubscriptionType
const remoteUri: string = remoteVersionConfigObj.uri || ''
return (
remoteVersionConfigObj.topic === localConfig.topic &&
remoteVersionConfigObj.uri === localConfig.uri &&
remoteUri.endsWith(localConfig.uri) &&
remoteVersionConfigObj.filter === localConfig.filter
)
}
Expand Down

0 comments on commit 822a80e

Please sign in to comment.