skip to Main Content

This morning my app started to crash (Error while trying to deserialize arguments) because of some Shopify jobs that couldn’t find a model (products_update_job).

After further investigation, I found that the code I’ve written in those jobs didn’t even try to search for a model, but merely deleted some Memcached tags.

I’ve been using the shopify_app gem to set up the webhooks and process them.

2

Answers


  1. Chosen as BEST ANSWER

    After a lot of digging and a bit of luck, I noticed that the webhooks response from Shopify contained a new field admin_graphql_api_id: gid://shopify/Product/817915723823. Then I started to do some more digging and learning about Global ID to find that "Support is automatically included in Active Record."

    So what happened was that Shopify started, overnight, to send the admin_graphql_api_id field that automatically triggered the model search, messing with my app.

    The fix was to add an initializer that bypasses the model search, doing nothing.

    I could use this feature to automatically find models but at times the app receives webhooks with products that aren't there anymore.

    config/initializers/global_id.rb

    GlobalID::Locator.use :shopify do |gid|
      # do nothing
    end
    

    Update

    One quick fix is to filter out that param

    def deserialize(job_data)
      sanitized_data = recursive_delete_gids(job_data)
      super(sanitized_data)
    end
    
    private
    
    def recursive_delete_gids(hash)
      hash.each do |key, value|
        case value
      when String
        hash.delete(key) if value.start_with? 'gid://'
      when Hash
        recursive_delete_gids(value)
      when Array
        value.each do |array_value|
          recursive_delete_gids(array_value) if array_value.is_a? Hash
        end
      end
    end
    

  2. I had nearly the identical problem yesterday from 10 am EST to ~6 pm. My app receives order payloads via webhook and queues them for processing using delayed_jobs. The error I got:

    E, [2018-06-18T22:25:43.927114 #51] ERROR — : 2018-06-18T22:25:43+0000: [Worker(host:e069195b1b97 pid:51)] Job ActiveJob::QueueAdapters::DelayedJobAdapter::JobWrapper (id=15571) (queue=webhook) FAILED (4 prior attempts) with ActiveJob::DeserializationError: Error while trying to deserialize arguments: uninitialized constant Order

    I believe this is caused by this attribute, that apparently is no longer being sent:

    admin_graphql_api_id: gid://shopify/Order/516…….

    I’m going to chnage my app to write the payloads off to a new table, and only serialize to delayed_jobs the ID of the payload record.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search