Fulfillment Creation Quietly Failing

Our application is failing to create fulfillments sometimes in Shopify, but we’re getting very little debug information back. Can someone help troubleshoot?

I didn’t include IDs to be safe, but here’s all the details!

ShopifyAPI::Fulfillment.save! is returning InvalidResource with no clarifying details (message and to_s just return Failed.).

The order we’re updating…

  • Has several items that are split in our system across two fulfillments. In our system, we’ve had to cancel and replace the fulfillment a few times, but that hasn’t been accepted in Shopify.
    • Instead, we made and shipped one fulfillment in shopify (correct), but the other allowed us to create and cancel a shipment once in Shopify, but we cannot create the new fulfillment to replace it.
  • The timeline in shopify looks like this:
    • Fulfillment 1 created
    • Fulfillment 2 created
    • Fulfillment 2 marked as fulfilled
    • Fulfillment 1 canceled
    • Fulfilment 2 delivered
  • (we’ve been trying to make the replacement for fulfillment 1 periodically since it was canceled)

We’re using ruby 2.6.7 and we’re just calling ShopifyAPI::Fulfillment new and save! sequentially.

The new call is: ShopifyAPI::Fulfillment.new(order_id, **arguments). I’ve confirmed we are always providing the shopify order ID and arguments always has this exact format:

{ location_id: int, exists in shopify, and always not nil,

tracking_number: nil,

status: “open”,

line_items: [

{ id: string, exists in shopify, and always not nil,

quantity: int, always not nil, and matches shopify in the cases I’ve seen)

}

]

}

Update - I’ve observed that some lines have fulfillable_quantity set to 0 even though the previous fulfillment was canceled. We don’t ever send fulfillable_quantity in our fulfillment API calls. Could it being 0 be the source? If so, what would cause and correct that?

Some orders don’t have anything that I’ve noted as odd. We are typically tying to partially fulfill an order though (only ship one of the lines). Are there rules to when that’s allowed?

On Friday (1/28/22) around 4pm Central Time, the issue resolved itself. Most of the orders fell into the bucket of “we created a fulfillment → canceled it → tried to replace it with 2+ fulfillments.”

I’m interested to hear if there was a Shopify fix around this time to ensure there’s not a subtle bug in our system.