Skip to content

Fix webhook handler dispatch with shopify_api v16 - #2084

Open
wehamed wants to merge 1 commit into
Shopify:mainfrom
wehamed:fix-2045-webhook-handler-instance
Open

Fix webhook handler dispatch with shopify_api v16#2084
wehamed wants to merge 1 commit into
Shopify:mainfrom
wehamed:fix-2045-webhook-handler-instance

Conversation

@wehamed

@wehamed wehamed commented Aug 9, 2026

Copy link
Copy Markdown

What this PR does

Update generated webhook jobs to implement the shopify_api v16
WebhookHandler dispatch contract:

def self.handle(data:)
  perform_later(
    topic: data.topic,
    shop_domain: data.shop,
    webhook: data.body,
  )
end

Generated jobs previously used the pre-v16
handle(topic:, shop:, body:, webhook_id:, api_version:) signature.
shopify_api v16 dispatches WebhookMetadata through handle(data:), so
registered webhook handlers raised ArgumentError during delivery.

This also conforms the webhook fixtures used across the test suite and adds
regression coverage through the real Registry dispatch path.

Fixes #2045

Reviewer's guide to testing

  1. Run bundle exec rake test.
  2. The regression test in test/shopify_app/managers/webhooks_manager_test.rb
    registers a job through WebhooksManager.add_registrations, then dispatches a
    real HMAC-signed webhook via ShopifyAPI::Webhooks::Registry.process, asserting
    the job is enqueued with the mapped topic / shop_domain / webhook arguments.
  3. Generator tests for add_webhook, add_app_uninstalled_job, and add_privacy_jobs
    now assert that generated jobs implement the v16 handle(data:) contract.

Things to focus on

  1. The generated handle(data:) contract and the data.topic / data.shop / data.body mapping.
  2. The regression test exercises the real Registry dispatch path rather than the mocked registration.
  3. CHANGELOG.md and docs/Upgrading.md examples updated to the v16 contract.

Checklist

Before submitting the PR, please consider if any of the following are needed:

  • Update CHANGELOG.md if the changes would impact users
  • Update README.md, if appropriate.
  • Update any relevant pages in /docs, if necessary
  • For security fixes, the Disclosure Policy must be followed.

Generated webhook jobs still used the pre-v16
handle(topic:, shop:, body:, webhook_id:, api_version:) signature.

shopify_api v16 dispatches WebhookMetadata through handle(data:), so
registered webhook handlers raise ArgumentError during delivery.

Update generated jobs to the v16 WebhookHandler contract and add
regression coverage through the real Registry dispatch path.

Fixes Shopify#2045
@github-actions github-actions Bot added cla-needed devtools-gardener Post the issue or PR to Slack for the gardener labels Aug 9, 2026
@wehamed

wehamed commented Aug 9, 2026

Copy link
Copy Markdown
Author

I have signed the CLA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devtools-gardener Post the issue or PR to Slack for the gardener

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebhooksManager passes class instead of instance to Registry.add_registration (incompatible with shopify_api v16)

1 participant