We subscribe to the shopify ‘order fulfilled’ webhook. For the past month we’ve had no problem at all parsing the data which is posted to us and taking action based on it. In particular, every request has contained a ‘customer’ array, consisting of (at least) ’email’, ‘first_name’ and ‘last_name’.
We have just received data without a ‘customer’ array. On superficial inspection, the order appears no different to any other order we’ve processed, so there’s no obvious reason why this would be the case.
The data we’ve received does contain an email, first_name, and last_name, but not in a ‘customer’ array. We could modify our code to look in other places to extract this data, but we’d rather not without understanding why we were making the change.
Has there been an announced change to the structure of the data Shopify posts that we’ve somehow missed?
What are the conditions which would cause the ‘customer’ array to not appear in the posted data? Is there any location in the posted data which is guaranteed to always contain email, first_name and last_name so we can prevent this happening again?
Your webhook handlers should handle the case were the customer information on an order is missing. This can happen in the legitimate case were a customer is deleted, which might be done manually by the merchant.
In your case specifically, the problem was that the customer was not getting associated with an order. This was a bug in a library Shopify uses for background job processing, which was not retrying jobs that got killed by the kernel for running out of memory. In this case the job would create a customer for an order for new customers. I have fixed the relevant bugs that should prevent background jobs from being lost in this situation.