TL;DR: We’ve been facing an error with a specific subscription that we can’t seem to be able to solve and the error message we receive is just Internal error fetching shipping rates for subscription contract
Some background context and more information:
Whenever a customer purchases a subscription, we get a subscription created webhook. From there, we retrieve the subscription from Shopify and verify if the lines that exist there correspond to the ones in the origin order. If the lines do not add up, it means that there are some items that do not belong to the subscription, and in those cases we want to recalculate the delivery price so it aligns to the items that will be on the next order.
To get the new shipping options, use the following query using the draft id and the original delivery addres:
query subscriptionDraftShippingOptions(
$draftId: ID!
$deliveryAddress: MailingAddressInput
) {
subscriptionDraft(id: $draftId) {
id
shippingOptions(deliveryAddress: $deliveryAddress) {
__typename
... on SubscriptionShippingOptionResultSuccess {
shippingOptions {
title
price {
amount
currencyCode
}
code
presentmentTitle
description
carrierService {
id
formattedName
}
}
}
}
}
}
For all (Except this subscription) request, we either get an empty array, a null value, or the information we need, and we can handle each of those, but this one is returning this error:
"data": {
"subscriptionDraft": {
"id": "gid://shopify/SubscriptionDraft/xxxxxx",
"shippingOptions": null
}
},
"errors": [
{
"message": "Internal error fetching shipping rates for subscription contract.",
"locations": [
{
"line": 4,
"column": 5
}
],
"path": [
"subscriptionDraft",
"shippingOptions"
]
}
]
Here are some example request ids:
d8e6b2c9-3466-4329-aa2b-8d7013aee50d
2d9c1143-bbdc-4175-9df2-cb5f2be8770d
580f1b00-b37d-4ec5-b0be-73e608e26d34