INTERAL_SERVER_ERROR while requesting a bulk operation on customerSegmentMembers with a filter on product purchase tag

Hi all!

I am creating a bulk operation to fetch customerSegmentMembers (querying by segmentId)

gql bulk query:

mutation {
  bulkOperationRunQuery(
    query: """
    {
        customerSegmentMembers(segmentId: "gid://shopify/Segment/1101338706247") {
            edges {
                node {
                    id
                }
            }
        }
    }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

and then i get this:

"data": {
    "currentBulkOperation": {
      "id": "gid://shopify/BulkOperation/7467090116935",
      "status": "FAILED",
      "errorCode": "INTERNAL_SERVER_ERROR",
      "createdAt": "2025-10-07T11:01:24Z",
      "completedAt": null,
      "objectCount": "0",
      "fileSize": null,
      "url": null,
      "partialDataUrl": null
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 1,
      "actualQueryCost": 1,
      "throttleStatus": {
        "maximumAvailable": 20000,
        "currentlyAvailable": 19999,
        "restoreRate": 1000
      }
    }
  }
}

the segment query is:

"segment": {
      "query": "products_purchased MATCHES (\n  tag CONTAINS 'ARGruppo1_PROFUMI',\n  date > -6m,\n  quantity >= 2\n) AND orders_placed MATCHES (\n  amount >= 100,\n  date > -6m\n)"
    }
  }

do you have any suggestions?

1 Like

Hey @valdozzz :waving_hand: - would you be able to share an X-Request-ID from the API response headers for an example where you’re seeing this error pop up? Any easy way to grab one of these is to use an API Client like Postman to replicate the issue and grab the request ID from the output response headers like this:

Once we have that, I’m happy to take a look at our logs on our end and look into why that error popped up for you. Hope to hear from you soon!

Hi Alan. sure!

x-request-id of the bulkOperationRunQuery mutation → a440679d-3f71-41eb-83e6-715bff2c2f9f-1759939582

x-request-id of the currentBulkOperation query → f4887cce-fc44-4737-9ba6-eaa0e90df0ae-1759939642

i see the INTERAL_SERVER_ERRROR on the currentBulkOperation query response

Hey @valdozzz :waving_hand: - thanks for sharing those request IDs, really appreciated! I did some testing on my end, and can confirm this is actually expected behaviour (although the generic internal server error message isn’t the most ideal for sure).

Right now, the customerSegmentMembers query can only be run as part of a specific async mutation (not as a bulk operation at the moment, unfortunately):

That should allow you to create and return the info you need though. Let me know if this works for you or if I can clarify anything on my end here :slight_smile:

Thanks a lot for clarifying!
Just to double-check — is this limitation for all queries, or only for those that use filters like product_purchased with the tag filter?

Because for other segments, the flow and the bulk operation seem to work correctly on my end.

Hey - thank you for clarifying too. I actually did some double checking on my end and ran a similar query on my test shop and was actually able to run the bulk operation successfully as well. Here’s the code I used to build the segment:

FROM customers
SHOW customer_name, note, email_subscription_status, location, orders, amount_spent
WHERE products_purchased MATCHES (
  tag CONTAINS 'ARGruppo1_PROFUMI',
  date > -6m,
  quantity >= 2
) AND orders_placed MATCHES (
  amount >= 100,
  date = -6m
)

I think this is close to what you had used. Can you let me know what happens when you run the async CustomerSegmentMembersQueryCreate mutation? Does the output generate for you? Just trying to narrow down and see if there’s potentially something happening with the output data itself, since I can confirm that the Bulk Operation query should work now after doing some testing on my end.

Hope to hear from you soon, we’ll get this looked into.

okay gotcha!

yes it works if we make the customerSegmentMembersQuery before the bulk operation.

so basically what we should do is:

  1. create an async customerSegmentMembersQuery

  2. then create a bulk operation with customerSegmentMembers(queryId: "previous_query_id")

right?

do we need to wait the first step to be done before going though the step 2?

thanks again Alan.

Valdo

Hey @valdozzz , thanks for trying that, glad that it runs the customerSegmentMembersQuery mutation. Would you be able to share an x-request-id for the output for that mutation as well if possible?

I think there may be an issue with the data being returned by the segment itself, and just want to compare the two outputs (the bulk operation and the async mutation). My thinking is that your original bulk operation query should work, but there may be an issue with the data itself, so you wouldn’t necessarily have to create the async query first and then integrate into the bulk operation.

Hope to hear from you soon.

Hey @valdozzz - just following up here to see if I can still help out, let me know!

Hey @valdozzz , just going to close this thread out for tracking, but let me know if I can help out further at all :slight_smile: