Closed m11o closed 1 year ago
This may be related to https://github.com/Shopify/shopify_app/issues/1659
It looks live we've got some work to do to clarify how mandatory webhooks are meant to be configured.
I haven't been able to reproduce this error following the pattern of handling mandatory GDPR webhooks with our app template.
It seems like the template vs your config has a different pattern for path
vs address
. I didn't dive too far into the differences between the two, but I wonder if there is something there. Can you try to modify your config to follow how our latest app templates work?
@nelsonwittwer the issue is still there. I was able to reproduce it with a clean app generated with shopify-app-template-ruby
. Below are exact steps to reproduce it:
npm run dev
and connect the Shopify app and dev store.npm run shopify app env pull
mv .env web/.env
cd web
bundle add dotenv-rails
rails console
and make sure make sure GDPR webhooks are loaded by calling ShopifyApp.configuration.webhooks
. It should return the following output:
=> [{:topic=>"app/uninstalled", :address=>"api/webhooks/app_uninstalled"},
{:topic=>"shop/redact", :address=>"api/webhooks/shop_redact"},
{:topic=>"customers/redact", :address=>"api/webhooks/customers_redact"},
{:topic=>"customers/data_request", :address=>"api/webhooks/customers_data_request"}]
session = ShopifyAPI::Auth::Session.new(shop: Shop.last.shopify_domain, access_token: Shop.last.shopify_token)
ShopifyApp::WebhooksManager.recreate_webhooks!(session: session)
This will raise an error:
/shopify_api-12.5.0/lib/shopify_api/webhooks/registry.rb:154:in `get_webhook_id':
Failed to fetch webhook from Shopify: Argument 'topics' on Field 'webhookSubscriptions' has
an invalid value (SHOP_REDACT). Expected type '[WebhookSubscriptionTopic!]' (ShopifyAPI::Errors::WebhookRegistrationError)
We definitely need GPDR webhooks to be present in the registry in order to have a handler for them too. But they shouldn't be used when we trying to register webhook via API.
Can we reopen and merge PR by @m11o with the fix for this problem? https://github.com/Shopify/shopify-api-ruby/pull/1124
Should be fixed with this app gem PR
Just upgraded to v 13 and experiencing this. Done a clean bundle install to ensure the latest gems.
/Users/..../.asdf/installs/ruby/3.0.4/lib/ruby/gems/3.0.0/gems/shopify_api-13.0.0/lib/shopify_api/webhooks/registry.rb:154:in
`get_webhook_id': Failed to fetch webhook from Shopify:
Argument 'topics' on Field 'webhookSubscriptions' has an invalid value (SHOP_REDACT).
Expected type '[WebhookSubscriptionTopic!]'. (ShopifyAPI::Errors::WebhookRegistrationError)
Snapshot of shopify_app form gemlock
# Gemfile.lcok
...
shopify_app (21.5.0)
activeresource
addressable (~> 2.7)
browser_sniffer (~> 2.0)
jwt (>= 2.2.3)
rails (> 5.2.1)
redirect_safely (~> 1.0)
shopify_api (~> 13.0)
sprockets-rails (>= 2.0.0)
...
Not sure how to move forward from here.
Also - getting this while running the recreate_webhooks!
from the shopify_app (also latest).
Just realised it's not just shop/redact
. Similar errors for customers/redact
and customers/data_request
Issue summary
I encountered an error when using this gem to register webhooks for mandatory webhooks (customers/redact, customers/data_request, shop/redact). According to Shopify's documentation, these webhooks can only be set up through the Shopify admin dashboard and cannot be registered via API. However, since the code for receiving and subscribing to webhooks is shared in this gem, attempting to register these webhooks through the code leads to an error.
The error message I received is:
Here's the code I used to register the webhook:
The simple code is:
shopify_api
version: 12.2.1Expected behavior
Topics excluding mandatory webhooks which we register webhooks can be registered.
Actual behavior
The bellow error occurred.
Steps to reproduce the problem