From 56fc3b487ccf9b3527964ca7c7508b6075b73b25 Mon Sep 17 00:00:00 2001 From: Liz Kenyon Date: Tue, 6 Jan 2026 14:10:45 -0600 Subject: [PATCH] Fix TypeError in webhook job templates with shopify_api >= 16.0.0 Unblock users experiencing TypeError when registering webhook handlers due to Sorbet type checking introduced in shopify_api-16.0.0 Changed to for ShopifyAPI::Webhooks::WebhookHandler in all webhook job templates. This makes the class object itself satisfy the WebhookHandler type expected by WebhooksManager.add_registrations Affected templates: - app_uninstalled_job.rb.tt - customers_data_request_job.rb.tt - customers_redact_job.rb.tt - shop_redact_job.rb.tt - webhook_job.rb.tt --- CHANGELOG.md | 1 + .../templates/app_uninstalled_job.rb.tt | 8 +++----- .../templates/customers_data_request_job.rb.tt | 8 +++----- .../add_privacy_jobs/templates/customers_redact_job.rb.tt | 8 +++----- .../add_privacy_jobs/templates/shop_redact_job.rb.tt | 8 +++----- .../shopify_app/add_webhook/templates/webhook_job.rb.tt | 8 +++----- 6 files changed, 16 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b77d2720a..f2708a2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ Unreleased ---------- +- [Patch] Fix sorbet errors in generated webhook handlers 23.0.1 (December 22, 2025) - Fix engine initialization [#2040](https://github.com/Shopify/shopify_app/pull/2040) diff --git a/lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt b/lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt index a441d2523..c60e7a444 100644 --- a/lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt +++ b/lib/generators/shopify_app/add_app_uninstalled_job/templates/app_uninstalled_job.rb.tt @@ -1,10 +1,8 @@ class AppUninstalledJob < ActiveJob::Base - include ShopifyAPI::Webhooks::WebhookHandler + extend ShopifyAPI::Webhooks::WebhookHandler - class << self - def handle(topic:, shop:, body:, webhook_id:, api_version:) - perform_later(topic: topic, shop_domain: shop, webhook: body) - end + def self.handle(topic:, shop:, body:, webhook_id:, api_version:) + perform_later(topic: topic, shop_domain: shop, webhook: body) end def perform(topic:, shop_domain:, webhook:) diff --git a/lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt b/lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt index 0aba51f74..aa98a1eff 100644 --- a/lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt +++ b/lib/generators/shopify_app/add_privacy_jobs/templates/customers_data_request_job.rb.tt @@ -1,10 +1,8 @@ class CustomersDataRequestJob < ActiveJob::Base - include ShopifyAPI::Webhooks::WebhookHandler + extend ShopifyAPI::Webhooks::WebhookHandler - class << self - def handle(topic:, shop:, body:, webhook_id:, api_version:) - perform_later(topic: topic, shop_domain: shop, webhook: body) - end + def self.handle(topic:, shop:, body:, webhook_id:, api_version:) + perform_later(topic: topic, shop_domain: shop, webhook: body) end def perform(topic:, shop_domain:, webhook:) diff --git a/lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt b/lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt index 4de29ba2f..9dc0a1716 100644 --- a/lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt +++ b/lib/generators/shopify_app/add_privacy_jobs/templates/customers_redact_job.rb.tt @@ -1,10 +1,8 @@ class CustomersRedactJob < ActiveJob::Base - include ShopifyAPI::Webhooks::WebhookHandler + extend ShopifyAPI::Webhooks::WebhookHandler - class << self - def handle(topic:, shop:, body:, webhook_id:, api_version:) - perform_later(topic: topic, shop_domain: shop, webhook: body) - end + def self.handle(topic:, shop:, body:, webhook_id:, api_version:) + perform_later(topic: topic, shop_domain: shop, webhook: body) end def perform(topic:, shop_domain:, webhook:) diff --git a/lib/generators/shopify_app/add_privacy_jobs/templates/shop_redact_job.rb.tt b/lib/generators/shopify_app/add_privacy_jobs/templates/shop_redact_job.rb.tt index a23e98490..f2c5b83de 100644 --- a/lib/generators/shopify_app/add_privacy_jobs/templates/shop_redact_job.rb.tt +++ b/lib/generators/shopify_app/add_privacy_jobs/templates/shop_redact_job.rb.tt @@ -1,10 +1,8 @@ class ShopRedactJob < ActiveJob::Base - include ShopifyAPI::Webhooks::WebhookHandler + extend ShopifyAPI::Webhooks::WebhookHandler - class << self - def handle(topic:, shop:, body:, webhook_id:, api_version:) - perform_later(topic: topic, shop_domain: shop, webhook: body) - end + def self.handle(topic:, shop:, body:, webhook_id:, api_version:) + perform_later(topic: topic, shop_domain: shop, webhook: body) end def perform(topic:, shop_domain:, webhook:) diff --git a/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt b/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt index 3a377f62f..09b3dc6a8 100644 --- a/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt +++ b/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt @@ -1,10 +1,8 @@ class <%= @job_class_name %> < ActiveJob::Base - include ShopifyAPI::Webhooks::WebhookHandler + extend ShopifyAPI::Webhooks::WebhookHandler - class << self - def handle(topic:, shop:, body:, webhook_id:, api_version:) - perform_later(topic: topic, shop_domain: shop, webhook: body) - end + def self.handle(topic:, shop:, body:, webhook_id:, api_version:) + perform_later(topic: topic, shop_domain: shop, webhook: body) end def perform(topic:, shop_domain:, webhook:)