Internal Server Error Bulk Operation orders

Hi,
I have an issue with a bulk operation with one specific order on my shop that instantly generates an Internal Server Error when I try to get it.
It’s a simple command just with 134 line items and I don’t know if it’s related to that.

Here is my bulk operation query :

{
  orders(
    query: "updated_at:>='2025-03-18T01:16:19.420Z' AND updated_at:<'2025-03-19T14:37:30.532Z'"
    sortKey: UPDATED_AT
  ) {
    edges {
      node {
        idemailclosedAtcreatedAtupdatedAtnotetestsubtotalPricetaxesIncludedcurrencyCodedisplayFinancialStatusconfirmedcustomerAcceptsMarketingnamecancelledAtcancelReasonphysicalLocation {
          id
        }
        processedAtphonecustomerLocaleclientIpdisplayFulfillmentStatusdiscountCodetotalCapturableSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalDiscountsSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalOutstandingSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalPriceSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalReceivedSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalRefundedSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalRefundedShippingSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalShippingPriceSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalTaxSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        currentTotalTaxSet {
          shopMoney {
            amountcurrencyCode
          }
        }
        totalWeightagreements {
          edges {
            node {
              idhappenedAtsales {
                edges {
                  node {
                    idlineTypequantity
                    ... on ProductSale {
                      lineItem {
                        id
                      }
                    }
                  }
                }
              }
            }
          }
        }
        tagscustomAttributes {
          keyvalue
        }
        customer {
          id
        }
        billingAddress {
          idfirstNamelastNamecompanyaddress1address2cityprovincecountryzipphonenameprovinceCodecountryCodeV2
        }
        billingAddressMatchesShippingAddressshippingAddress {
          idfirstNamelastNamecompanyaddress1address2cityprovincecountryzipphonenameprovinceCodecountryCodeV2
        }
        publication {
          idname
        }
        paymentGatewayNamestaxLines {
          priceSet {
            shopMoney {
              amountcurrencyCode
            }
          }
          rateratePercentagetitle
        }
        refunds {
          id
        }
        transactions {
          idaccountNumberamountSet {
            shopMoney {
              amountcurrencyCode
            }
          }
          authorizationCodecreatedAterrorCodeformattedGatewaygatewaykindmanuallyCapturablemaximumRefundableV2 {
            amountcurrencyCode
          }
          parentTransaction {
            id
          }
          paymentIdprocessedAtstatustesttotalUnsettledSet {
            shopMoney {
              amountcurrencyCode
            }
          }
        }
        lineItems {
          edges {
            node {
              idcustomAttributes {
                keyvalue
              }
              discountAllocations {
                allocatedAmountSet {
                  shopMoney {
                    amountcurrencyCode
                  }
                }
                discountApplication {
                  indexallocationMethodtargetSelectiontargetType
                }
              }
              discountedTotalSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              discountedUnitPriceSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              duties {
                idcountryCodeOfOriginharmonizedSystemCodeprice {
                  shopMoney {
                    amountcurrencyCode
                  }
                }
                taxLines {
                  priceSet {
                    shopMoney {
                      amountcurrencyCode
                    }
                  }
                  rateratePercentagetitle
                }
              }
              fulfillableQuantityfulfillmentService {
                idtypeserviceName
              }
              fulfillmentStatusmerchantEditablenamenonFulfillableQuantityoriginalTotalSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              originalUnitPriceSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              product {
                id
              }
              quantityrefundableQuantityrequiresShippingrestockableskutaxLines {
                priceSet {
                  shopMoney {
                    amountcurrencyCode
                  }
                }
                rateratePercentagetitle
              }
              taxabletitletotalDiscountSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              unfulfilledDiscountedTotalSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              unfulfilledOriginalTotalSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              unfulfilledQuantityvariant {
                id
              }
              variantTitlevendorsellingPlan {
                namesellingPlanId
              }
            }
          }
        }
        shippingLines {
          edges {
            node {
              idcarrierIdentifiercodecustomdeliveryCategorydiscountAllocations {
                allocatedAmountSet {
                  shopMoney {
                    amountcurrencyCode
                  }
                }
                discountApplication {
                  indexallocationMethodtargetSelectiontargetType
                }
              }
              discountedPriceSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              originalPriceSet {
                shopMoney {
                  amountcurrencyCode
                }
              }
              phonerequestedFulfillmentService {
                idtypeserviceName
              }
              shippingRateHandlesourcetaxLines {
                priceSet {
                  shopMoney {
                    amountcurrencyCode
                  }
                }
                rateratePercentagetitle
              }
              title
            }
          }
        }
      }
    }
  }
}

Here is a bulk operation that failed : gid://shopify/BulkOperation/6384643703130
Here is the order that makes it fail : gid://shopify/Order/6608842064218
Here is the shop : bonsoirs.myshopify.com

Would somebody have any insights about this?

1 Like

This is the error I got:

"Invalid bulk query: Field 'idemailclosedAtcreatedAtupdatedAtnotetestsubtotalPricetaxesIncludedcurrencyCodedisplayFinancialStatusconfirmedcustomerAcceptsMarketingnamecancelledAtcancelReasonphysicalLocation' doesn't exist on type 'Order'"

You will need to update query to include those fields properly like this:

mutation {
  bulkOperationRunQuery(
    query: """
        {
      orders(
        query: "updated_at:>='2024-11-18T01:16:19.420Z' AND updated_at:<'2025-03-19T14:37:30.532Z'"
        sortKey: UPDATED_AT
      ) {
        edges {
          node {
            id
            email
            closedAt
            createdAt
            updatedAt
            note
            test
            subtotalPrice
            taxesIncluded
            currencyCode
            displayFinancialStatus
            confirmed
            customerAcceptsMarketing
            name
            cancelledAt
            cancelReason
            physicalLocation {
              id
            }
            processedAt
            phone
            customerLocale
            clientIp
            displayFulfillmentStatus
            discountCode
            totalCapturableSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalDiscountsSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalOutstandingSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalPriceSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalReceivedSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalRefundedSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalRefundedShippingSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalShippingPriceSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalTaxSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            currentTotalTaxSet {
              shopMoney {
                amount
                currencyCode
              }
            }
            totalWeight
            agreements {
              edges {
                node {
                  id
                  happenedAt
                  sales {
                    edges {
                      node {
                        id
                        lineType
                        quantity
                        ... on ProductSale {
                          lineItem {
                            id
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
            tags
            customAttributes {
              key
              value
            }
            customer {
              id
            }
            billingAddress {
              id
              firstName
              lastName
              company
              address1
              address2
              city
              province
              country
              zip
              phone
              name
              provinceCode
              countryCodeV2
            }
            billingAddressMatchesShippingAddress
            shippingAddress {
              id
              firstName
              lastName
              company
              address1
              address2
              city
              province
              country
              zip
              phone
              name
              provinceCode
              countryCodeV2
            }
            publication {
              id
              name
            }
            paymentGatewayNames
            taxLines {
              priceSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              rate
              ratePercentage
              title
            }
            refunds {
              id
            }
            transactions {
              id
              accountNumber
              amountSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              authorizationCode
              createdAt
              errorCode
              formattedGateway
              gateway
              kind
              manuallyCapturable
              maximumRefundableV2 {
                amount
                currencyCode
              }
              parentTransaction {
                id
              }
              paymentId
              processedAt
              status
              test
              totalUnsettledSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
            }
            lineItems {
              edges {
                node {
                  id
                  customAttributes {
                    key
                    value
                  }
                  discountAllocations {
                    allocatedAmountSet {
                      shopMoney {
                        amount
                        currencyCode
                      }
                    }
                    discountApplication {
                      index
                      allocationMethod
                      targetSelection
                      targetType
                    }
                  }
                  discountedTotalSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  discountedUnitPriceSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  duties {
                    id
                    countryCodeOfOrigin
                    harmonizedSystemCode
                    price {
                      shopMoney {
                        amount
                        currencyCode
                      }
                    }
                    taxLines {
                      priceSet {
                        shopMoney {
                          amount
                          currencyCode
                        }
                      }
                      rate
                      ratePercentage
                      title
                    }
                  }
                  fulfillableQuantity
                  fulfillmentService {
                    id
                    type
                    serviceName
                  }
                  fulfillmentStatus
                  merchantEditable
                  name
                  nonFulfillableQuantity
                  originalTotalSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  originalUnitPriceSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  product {
                    id
                  }
                  quantity
                  refundableQuantity
                  requiresShipping
                  restockable
                  sku
                  taxLines {
                    priceSet {
                      shopMoney {
                        amount
                        currencyCode
                      }
                    }
                    rate
                    ratePercentage
                    title
                  }
                  taxable
                  title
                  totalDiscountSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  unfulfilledDiscountedTotalSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  unfulfilledOriginalTotalSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  unfulfilledQuantity
                  variant {
                    id
                  }
                  variantTitle
                  vendor
                  sellingPlan {
                    name
                    sellingPlanId
                  }
                }
              }
            }
            shippingLines {
              edges {
                node {
                  id
                  carrierIdentifier
                  code
                  custom
                  deliveryCategory
                  discountAllocations {
                    allocatedAmountSet {
                      shopMoney {
                        amount
                        currencyCode
                      }
                    }
                    discountApplication {
                      index
                      allocationMethod
                      targetSelection
                      targetType
                    }
                  }
                  discountedPriceSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  originalPriceSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  phone
                  requestedFulfillmentService {
                    id
                    type
                    serviceName
                  }
                  shippingRateHandle
                  source
                  taxLines {
                    priceSet {
                      shopMoney {
                        amount
                        currencyCode
                      }
                    }
                    rate
                    ratePercentage
                    title
                  }
                  title
                }
              }
            }
          }
        }
      }
    }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

I have checked the query and bulk operation created successfully.

{
  "data": {
    "bulkOperationRunQuery": {
      "bulkOperation": {
        "id": "gid://shopify/BulkOperation/1234567890",
        "status": "CREATED"
      },
      "userErrors": []
    }
  }

No error occurs when running the query.

Bulk operation is running every time except when one special command is in the updatedAt range, then it fails 100% of the time.

I copy pasted it bad, the query is this one :

{
  orders(
    query: "updated_at:>='2025-03-18T17:08:57.000Z' AND updated_at:<'2025-03-18T17:09:00.000Z'"
    sortKey: UPDATED_AT
  ) {
    edges {
      node {
        id
        email
        closedAt
        createdAt
        updatedAt
        note
        test
        subtotalPrice
        taxesIncluded
        currencyCode
        displayFinancialStatus
        confirmed
        customerAcceptsMarketing
        name
        cancelledAt
        cancelReason
        physicalLocation {
          id
        }
        processedAt
        phone
        customerLocale
        clientIp
        displayFulfillmentStatus
        discountCode
        totalCapturableSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalDiscountsSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalOutstandingSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalPriceSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalReceivedSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalRefundedSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalRefundedShippingSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalShippingPriceSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalTaxSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        currentTotalTaxSet {
          shopMoney {
            amount
            currencyCode
          }
        }
        totalWeight
        agreements {
          edges {
            node {
              id
              happenedAt
              sales {
                edges {
                  node {
                    id
                    lineType
                    quantity
                    ... on ProductSale {
                      lineItem {
                        id
                      }
                    }
                  }
                }
              }
            }
          }
        }
        tags
        customAttributes {
          key
          value
        }
        customer {
          id
        }
        billingAddress {
          id
          firstName
          lastName
          company
          address1
          address2
          city
          province
          country
          zip
          phone
          name
          provinceCode
          countryCodeV2
        }
        billingAddressMatchesShippingAddress
        shippingAddress {
          id
          firstName
          lastName
          company
          address1
          address2
          city
          province
          country
          zip
          phone
          name
          provinceCode
          countryCodeV2
        }
        publication {
          id
          name
        }
        paymentGatewayNames
        taxLines {
          priceSet {
            shopMoney {
              amount
              currencyCode
            }
          }
          rate
          ratePercentage
          title
        }
        refunds {
          id
        }
        transactions {
          id
          accountNumber
          amountSet {
            shopMoney {
              amount
              currencyCode
            }
          }
          authorizationCode
          createdAt
          errorCode
          formattedGateway
          gateway
          kind
          manuallyCapturable
          maximumRefundableV2 {
            amount
            currencyCode
          }
          parentTransaction {
            id
          }
          paymentId
          processedAt
          status
          test
          totalUnsettledSet {
            shopMoney {
              amount
              currencyCode
            }
          }
        }
        lineItems {
          edges {
            node {
              id
              customAttributes {
                key
                value
              }
              discountAllocations {
                allocatedAmountSet {
                  shopMoney {
                    amount
                    currencyCode
                  }
                }
                discountApplication {
                  index
                  allocationMethod
                  targetSelection
                  targetType
                }
              }
              discountedTotalSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              discountedUnitPriceSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              duties {
                id
                countryCodeOfOrigin
                harmonizedSystemCode
                price {
                  shopMoney {
                    amount
                    currencyCode
                  }
                }
                taxLines {
                  priceSet {
                    shopMoney {
                      amount
                      currencyCode
                    }
                  }
                  rate
                  ratePercentage
                  title
                }
              }
              fulfillableQuantity
              fulfillmentService {
                id
                type
                serviceName
              }
              fulfillmentStatus
              merchantEditable
              name
              nonFulfillableQuantity
              originalTotalSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              originalUnitPriceSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              product {
                id
              }
              quantity
              refundableQuantity
              requiresShipping
              restockable
              sku
              taxLines {
                priceSet {
                  shopMoney {
                    amount
                    currencyCode
                  }
                }
                rate
                ratePercentage
                title
              }
              taxable
              title
              totalDiscountSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              unfulfilledDiscountedTotalSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              unfulfilledOriginalTotalSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              unfulfilledQuantity
              variant {
                id
              }
              variantTitle
              vendor
              sellingPlan {
                name
                sellingPlanId
              }
            }
          }
        }
        shippingLines {
          edges {
            node {
              id
              carrierIdentifier
              code
              custom
              deliveryCategory
              discountAllocations {
                allocatedAmountSet {
                  shopMoney {
                    amount
                    currencyCode
                  }
                }
                discountApplication {
                  index
                  allocationMethod
                  targetSelection
                  targetType
                }
              }
              discountedPriceSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              originalPriceSet {
                shopMoney {
                  amount
                  currencyCode
                }
              }
              phone
              requestedFulfillmentService {
                id
                type
                serviceName
              }
              shippingRateHandle
              source
              taxLines {
                priceSet {
                  shopMoney {
                    amount
                    currencyCode
                  }
                }
                rate
                ratePercentage
                title
              }
              title
            }
          }
        }
      }
    }
  }
}

There are no errors with the query itself because it runs everytime usually, just this order specificaly makes the request throw an error

Could you please share the error?

Just an “internal server error” without any other informations :
“status”: “FAILED”,
“errorCode”: “INTERNAL_SERVER_ERROR”,
“id”: “gid://shopify/BulkOperation/6397710401882”

I noticed in the Shopify documentation that “Querying resources using a range search might timeout or return an error if the collection of resources is sufficiently large.” Could you please try the query with basic information to check if it works?

query: “updated_at:>=‘2025-03-18T17:08:57.000Z’ AND updated_at:<‘2025-03-18T17:09:00.000Z’”

@Noe_Morvillers mentioned this would return only 1 order.

Yeah this query is usually able to return up to 500 000 orders easily, here for only one order I get the 500 error

May I know the order details? Could you please share the order details?

It’s a classic order, the only different thing is that it has 134 line items, but you would think Shopify could handle this

Can you create a test order with the same number of line items as the issue order and try the bulk mutation for debugging?

I have already noticed that Shopify bulk operation has an issue with orders with many line items. The only workaround I have found that works, is to use non-bulk queries.

What I do is if I my bulk operation returns with an InternalServerError, I retry the query non-bulk. Of course this defeats the purpose of bulk operations, and requires me to maintain a whole bunch of extra code, but until Shopify fixes this, I have no other option.

I agree that this is unacceptable from Shopify’s part, this should be fixed.

I did and the problem looks like it comes from the number of line items, when I arrive at more than 70/80 line items I’m starting to get internal server errors

Yeah I might end up doing that but it’s really bad that Shopify is pushing their bulk operation and you have to deal with problems like that

Hey @Noe_Morvillers

I’m happy help take a look at this closer with you and see if we can get this reported to our dev teams. Reading the thread above, have you tested your bulk query on this order while excluding the lines? It sounds like testing has been done on orders up to a certain size. I’m just curious in this specific case if it will proceed without the order line items requests to confirm what was reported above.

To ensure I can look up recent logs, if possible, can you also attempt this one more time and log the x-request-id from the response headers of the bulkOperationRunQuery request?