[GraphQL] Internal error fetching shipping rates for subscription contract

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

Hi :waving_hand:

I’m sorry that you’re bumping into this issue. Our current understanding is that this problem happens in contracts that have a large number of line items. I’m afraid the only workaround this today is reducing the number of line items, which I understand is not always an option.

We are looking into fixing this and will let you know once the fix is live.

This is exactly the case!

Is there a magic number of lines that wouldn’t make the request fail? The reason I ask is because we’d want to either skip recalculating whenever that number is hit, or know when the “Internal error…” message is due to a reason other than a high number of lines.

I don’t want to end up assuming that every time that generic error is shown is due to a high line count

Has there been any update / fix here? We’re still seeing the same issue

Hi,

Our developers have just deployed a fix for this issue. Please can you test and let us know if the problem persists.

1 Like

Hi Brian_s,

Our developers have just deployed a fix for this issue. Please can you try again and let us know if the problem persists.

:raising_hands: Yes! In my quick tests with many lines this is now working. Thanks so much to the team! This’ll be beneficial to a lot of merchants

1 Like

Very glad to hear it!