[BUG] Subscription with high number of Billing Attempts returns an error

Hi there - We’ve found that if a subscription has hundreds of billing attempts that it’s no longer possible to fetch the billing attempts for the subscription contract.

here’s a Request ID to help with debugging: bc55d4d5-5fd4-458c-99e4-6a4f22fabc74-1723475491

Thanks in advance for your help!

Hello @Brian_S_1 ,

Can you share your query and how many billing attempts? I was able to create 500 billing attempts and then query the first 100 of them off of the contract.


query contracts {
subscriptionContracts(first: 1, reverse: true) {
edges {
node {
id
billingAttempts(first: 100) {
edges {
node {
id
}
}
}
}
}
}
}

Thanks! Here’s one with 523 billing attempts (almost all failed) and very close to each other: gid://shopify/SubscriptionContract/13066567746

I’m just trying to get the first 20 billing attempts

query getSubscriptionContract($id: ID!) {
	subscriptionContract(id: $id) {
		id
		billingAttempts(first: 20) {
			edges {
				node {
					subscriptionContract {
						lines (first: 1) {
							nodes {
								productId
								variantId
							}
						}
					}
					createdAt
					id
					completedAt
					 
					errorMessage
					errorCode
					ready
					idempotencyKey
					nextActionUrl
					order {
						id
						name
						 displayFinancialStatus
						displayFulfillmentStatus
						cancelledAt
						totalDiscountsSet { shopMoney {amount}}
					}
				}
			}
			pageInfo {
				hasNextPage
			}
		}
		
	}
}

response:

{
	"errors": [
		{
			"message": "Internal error. Looks like something went wrong on our end.\nRequest ID: baa952ee-5890-4347-a03c-1ac27776bea9-1723478468 (include this in support requests).",
			"extensions": {
				"code": "INTERNAL_SERVER_ERROR",
				"requestId": "baa952ee-5890-4347-a03c-1ac27776bea9-1723478468"
			}
		}
	]
}

Hi @Brian_S_1 .

I had a look into this for you.

There are billing attempts for that contract with the SubscriptionBillingAttemptErrorCode INSUFFICIENT_INVENTORY which is only set on billing attempts created using API Version 2024-07 or later.

However, the GraphQL request in question specified API Version 2024-01. If you’re able to use 2024-07 or later you should see the expected response.

See: https://shopify.dev/docs/api/release-notes/2024-07#billing-attempts

Best wishes,

Paul

Oh wow.. ok that’s good to know. Definitely seems like a bug and/or very important missing info in the documentation.

Thanks! Good to know once we’ve upgraded fully we’ll be ok

Hi @Brian_S_1

You should be longer receive an error when using older versions of the API to query billing attempts. If the API version used to make the request doesn’t support a specific error code stored on the billing attempt, you’ll receive an UNEXPECTED_ERROR code for that billing attempt instead.

Best wishes,

Paul

Thanks so much for getting on the fix so quickly!