-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webhooks throwing error when deserializing admin_graphql_api_id #600
Comments
Which webhook event type is this happening for? |
I saw it on themes/publish: ActiveJob::DeserializationError: Error while trying to deserialize arguments: uninitialized constant Theme I ended up adding a fake |
Thanks. Looks like an unintended side effect caused by a change that was released this morning. I've passed this information on to the responsible team and they will look into it. |
@adrianthedev I've been investigating a fix for this and a custom locator was my first thought as well however it doesn't fix the problem for everyone. Do you have a class defined in your application which matches up the resource of the webhook you're receiving? ie: if its a webhook from Another problem is here: https://github.com/rails/globalid/blob/5bfe23a8ab3ab49c9050bc3ad0668f5c01492cf6/lib/global_id/locator.rb#L17
|
yes. I have a class |
The quickest quickfix is to have dummy (empty) models for everything you expect to receive in webhooks until this is fixed properly from shopify. |
I'm working on a potential upstream fix to GlobalID which combined with a custom locator (that shopify_app will define) would fix this. It looks like the best solution so far. |
Sounds good! |
I ended up filtering out all of the Global IDs from the webhook data for now.
|
There's another alternative solution which may be worthwhile regardless. Shopify webhooks take a If you only want a subset of the fields, it's a good practice to use anyway to reduce the payload size. In this case, it could be used to set a whitelist and not include |
This is what I'm using for the # Class used to prevent ActiveJob and GlobalId from erroring when
# the Shopify API sends GlobalID inside of the GraphQL API
#
# e.g. "admin_graphql_api_id":"gid://shopify/Theme/11810989"
#
class Theme
include GlobalID::Identification
# No-op
def self.find(*args)
nil
end
end |
I think you could combine two strategies like this: # config/initializers/global_id.rb
GlobalID::Locator.use :shopify do |gid|
end
Theme = Class.new
# define others as needed Then the class will exist, but locator should just return the string back. |
yes, but you still need to define all classes. |
I am seeing a similar issue, woke up to thousands of failed ProductCreateJobs in resque. We are seeing the errors in ProductsCreateJob, which is weird since we define product.rb < ActiveRecord::Base. Any advice on how we should proceed in fixing this in the short term? |
this is the best short term @talecK |
IMHO the best thing would be to have a |
We are exploring the possibility of removing this field from the webhook payloads we send temporarily, until we can work out the details here. |
One class WebhooksController < ShopifyApp::WebhooksController
[...]
webhook_data = Base64.encode64(webhook_params.to_json)
MyJob.perform_later(shop_domain: shop_domain, webhook: webhook_data) class ProductsUpdateJob < ActiveJob::Base
def perform(shop_domain:, webhook:)
# NOTE: Temporary fix for gid deserialization error
if webhook.is_a?(String)
webhook = JSON.parse(Base64.decode64(webhook))
end
# Continue on to use webhook var as if it was a Hash
[...]
end
end |
We are no longer sending this field in webhook payloads for now. |
Thanks @eapache! |
@eapache If this field will be included again in the future can we get a bit more info on the timelines and recommended handling once available? Thanks. |
Absolutely, we'll post that information before we expose the field again. |
I'm going to close this issue for now as we're no longer including this field for new webhooks since yesterday around ~7 PM EST (23:00 UTC). The For consistency (and usefulness), they will ideally be included in webhooks again soon once we come up with a solution. This will likely involve having to update to a newer version of this gem though. |
Thanks @swalkinshaw & @eapache If bringing those fields back ends up requiring a gem update for apps to continue working it would be good to have plenty of notice. What's the best channel to monitor for updates? |
Any update on adding admin_graphql_api_id back to webhooks requests? |
Update: We will be re-adding the The ActiveJob behaviour which caused this issue actually caused a CVE anyway and has since been fixed. #771 will bump the Rails dependency requirement. Thanks to @chrisbutcher for following-up on this 👏. We'll comment in here once this has finally landed. |
v10.0.0 is now released. |
We started to receive webhook data including the new
admin_graphql_api_id
attribute today. This has a value of something akin togid://shopify/Customer/61476333152
.The default WebhooksController is serializing the entire hash into the job request. When ActiveJob tries to deserialize the object, it's looking at these gid's and trying to deserialize them into ActiveRecord objects. Since these objects don't exist on our system, we get an
ActiveJob::DeserializationError
.I think I can work around this by creating a custom WebhooksController that deletes all of the
admin_graphql_api_id
attributes, but I'd like to see a more long-term fix in shopify_app.The text was updated successfully, but these errors were encountered: