Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Bulk operation fails with INTERNAL_SERVER_ERROR when order doesn't have shipping address

Solved

Bulk operation fails with INTERNAL_SERVER_ERROR when order doesn't have shipping address

JeffTalbot
Shopify Partner
16 1 1

Hello,

 

I am getting an INTERNAL_SERVER_ERROR for some stores when running the query below. It appears that I only get the error if the store has fulfillment orders without shipping address (destination) information, which is the case for some dev stores where the orders were programmatically generated. If I remove the "destination" field from the GraphQL request, the bulk operation completes successfully for these stores.

 

The x-request-id for an example request that is failing, if the Shopify team could investigate: 61596f5a-35f0-4da0-8b8e-bf1b861c8bc6

 

I can work around this by generating shipping addresses for all orders in dev stores, but I am wondering if this error could ever happen on production stores? It seems like the destination data should just come back empty if there is no shipping address associated with a fulfillment order instead of causing an internal server error.

 

Query I'm using:

mutation {
bulkOperationRunQuery(
query: """
{
orders(query: "updated_at:>'2023-04-09T21:19:21Z' status:'any'") {
edges {
node {
id
createdAt
note
name

fulfillmentOrders {
edges {
node {
id
createdAt
updatedAt
assignedLocation {
location {
id
}
}

deliveryMethod {
methodType
}

fulfillAt
fulfillBy

fulfillmentHolds {
reason
reasonNotes
}

status

destination {
address1
address2
city
company
countryCode
email
firstName
lastName
phone
province
zip
}
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

 

Accepted Solution (1)

JeffTalbot
Shopify Partner
16 1 1

This is an accepted solution.

Following up on my own post here as I was able to get help from Shopify developers. The issue was not that the orders were missing shipping addresses. It was actually caused by including protected customer fields  (phone number and email) in the query that my app did not have permission to access. I guess at least at this time that requesting fields you don't have access to in the bulk API will trigger an INTERNAL_SERVER_ERROR. The solution is to remove those fields or request permission for them.

View solution in original post

Reply 1 (1)

JeffTalbot
Shopify Partner
16 1 1

This is an accepted solution.

Following up on my own post here as I was able to get help from Shopify developers. The issue was not that the orders were missing shipping addresses. It was actually caused by including protected customer fields  (phone number and email) in the query that my app did not have permission to access. I guess at least at this time that requesting fields you don't have access to in the bulk API will trigger an INTERNAL_SERVER_ERROR. The solution is to remove those fields or request permission for them.