GraphQL Bulk Operation for orders failing with INTERNAL_SERVER_ERROR when having a lot of sales

I am having issues only on a few specific orders, requesting order information using a bulk operation for the Orders endpoint.

I am getting the following error

  "currentBulkOperation": {
            "id": "gid://shopify/BulkOperation/5233612194023",
            "status": "FAILED",
            "errorCode": "INTERNAL_SERVER_ERROR",
            "createdAt": "2025-01-23T14:31:39Z",
            "completedAt": null,
            "objectCount": "22811",
            "fileSize": null,
            "url": null,
            "partialDataUrl": null
        }

The only thing that the orders have in common is that they have a lot of sales within an agreement.

The operation successfully starts, when I poll for the result, the status changes to “Running”, however after a while the status changes to “FAILED”, and the response is as shown above (For the example in this topic, the first poll that showed a “FAILED” status was at 2025-01-23T14:33:26Z ).

The request id for the request initiating the bulk operation is faba3bf3-f9d9-4f97-a64a-511d8c3be15d-1737642699. The bulk operation id is gid://shopify/BulkOperation/5233612194023 (as indicated in the response above)

This is my query

mutation{
    bulkOperationRunQuery(
        query:"""
    {
     orders( query: "ids:'############'") {
    edges {
      node {
          ...order
      }
    }
  }
    }

    fragment order on Order{
    id
      legacyResourceId
      createdAt
      fullyPaid
      displayFinancialStatus
      cancelledAt
      paymentGatewayNames
      totalPriceSet{
          ...money
      }
      taxesIncluded
      processedAt
      totalOutstandingSet{
          presentmentMoney{
              amount
          }
      }
    
    agreements {
        edges{
        node {
          id
          sales {
              pageInfo{
                hasNextPage
            }

            edges {
              node {
                  
                actionType
                
                totalAmount {
                  ...money
                }
                
              }
            }
            
          }
        }
        }
    }
    lineItems{
        edges{
            node{
                
                id
                duties{
                    countryCodeOfOrigin
                    harmonizedSystemCode
                    taxLines{
                        title
                        priceSet{
                            shopMoney{
                                amount
                            }
                        }
                    }
                    price{
                        shopMoney{
                            amount
                        }
                    }
                }
            }
        }
    }
    
    shippingLines{
        edges{
            node{
                id
                discountedPriceSet{
                    ...money
                }
                taxLines{
                    priceSet{
                        ...money
                    }
                }
            }
        }
        
    }
    transactions{
        id
        kind
        amountSet{
            ...money
        }
        status
        gateway
        processedAt
        totalUnsettledSet{
            ...money
        }
        fees{
            flatFee{
                amount
            }
            flatFeeName
            rate
            rateName
            taxAmount{
                amount
            }
            amount{
                amount
            }
        }
    }
}

    fragment money on MoneyBag{
    shopMoney{
        amount
    }
    presentmentMoney{
        amount
    }
    }
    """
    ){
        bulkOperation{
            id
            status
        }
        userErrors{
            field
            message
        }
    }
}

Hi,

I’ve connected with the relevant product team on this and will post an update when I hear more. In the meantime though, there have been timeout issues with bulkOperationRunQuery that are not necessarily related to the order count or complexity. These might be due to errors occurring before reaching the database, such as a ‘no cookie provided’ error.

Hi again,

It looks like the issue is from this line on your query:

     orders( query: "ids:'############'") {

It should be id - not ids . Because this filter does not exist, the bulk operation tries to retrieve all orders and it failed due to timeout error.

Actually in the code I do use ID, not IDs only in the sample that I tried to reproduce it in Postman did I use Ids.

Anyway I changed it to Id, same issue. Here is an updated response

"currentBulkOperation": {
            "id": "gid://shopify/BulkOperation/5251677716711",
            "status": "FAILED",
            "errorCode": "INTERNAL_SERVER_ERROR",
            "createdAt": "2025-01-28T13:48:46Z",
            "completedAt": null,
            "objectCount": "212",
            "fileSize": null,
            "url": null,
            "partialDataUrl": "https://storage.googleapis.com/shopify-tiers-assets-prod-us-east1/bulk-operation-outputs/omitted-for-security%2Fjsonl"
        }

If you test this on the GraphiQL app, does this work?

No

 "currentBulkOperation": {
      "id": "gid://shopify/BulkOperation/6190335820085",
      "status": "FAILED",
      "errorCode": "INTERNAL_SERVER_ERROR",
      "createdAt": "2025-01-28T16:36:35Z",
      "completedAt": null,
      "objectCount": "234",
      "fileSize": null,
      "url": null,
      "partialDataUrl": "https://storage.googleapis.com/shopify-tiers-assets-prod-us-east1/bulk-operation-outputs/omitted.jsonl",
      "__typename": "BulkOperation"
    }