Returns INTERNAL_SERVER_ERROR only for specific data when requesting bulkOperationRunMutation

Summary

We are developing a function to register products in bulk.
The function is implemented using bulkOperationRunMutation.

It was working fine with test data, but when we tried to register products using actual product data, we encountered a phenomenon that returned INTERNAL_SERVER_ERROR for some data.

I have tried with various data, but I am having trouble with the following situation for some data. Does anyone know a solution?

  • The bulkOperationRunMutation request itself is not accepted, resulting in an INTERNAL_SERVER_ERROR (not that the bulk operation request passed and an INTERNAL_SERVER_ERROR was returned after processing by shopify, but that the request itself was not accepted).
  • I don’t know what kind of data causes this phenomenon, or what the pattern of NG data is.
  • Even in the case of NG data, if the products are divided one by one and registered using bulkOperationRunMutation, all requests are approved and the products can be created.
  • If only a few characters are changed in the “descriptionHTML” of some NG data, the request may pass and the product may be created.

The following is masked data, not actual NG data, but actual NG data can be provided to shopify support.

Details

API

The following is used with mutation=productCreate.
https://shopify.dev/api/admin-graphql/2021-10/mutations/bulkoperationrunmutation

Request

mutation query

mutation bulkOperationRunMutation($mutation: String!, $stagedUploadPath: String!) {
  bulkOperationRunMutation(
      mutation: $mutation,
      stagedUploadPath: $stagedUploadPath
  ) {
    userErrors {
      code
      field
      message
    }
    bulkOperation {
      id
      status
      query
      createdAt
      errorCode
    }
  }
}

variables

$mutation: call($input: ProductInput!) {
  productCreate(input: $input) {
    userErrors {
      field
      message
    }
    product {
      id
      handle
      createdAt
      variants(first: 2) {
        edges {
          node {
            id
          }
        }
      }
    }
  }
}

$stagedUploadPath: tmp/43751473305/bulk/0b054c39-a773-4b1b-a8bf-dbf0dd5c7d5e/e70946a8-2fb8-4457-96b1-d64c0d8d124c-43513137-9170-4650-92f6-3387780e6164

stagedUploadPath Content example (NOTE: {uuid}=uuid string)

{"input":{"vendor":"XXX","handle":"{uuid}","title":"XXX","descriptionHtml":"XXX\u003cbr\u003e\u003cbr\u003eXXX\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e","status":"DRAFT","tags":["XXX"],"images":[{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"}],"variants":[{"price":1524,"compareAtPrice":1605,"taxable":false,"inventoryManagement":"SHOPIFY","inventoryPolicy":"DENY","inventoryQuantities":{"availableQuantity":0,"locationId":"gid://shopify/Location/XXX"}}]}}
{"input":{"vendor":"XXX","handle":"{uuid}","title":"XXX","descriptionHtml":"XXX\u003cbr\u003e\u003cbr\u003eXXX\u003cbr\u003e\u003cbr\u003e","status":"DRAFT","tags":["XXX"],"images":[{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"}],"variants":[{"price":1118,"compareAtPrice":1177,"taxable":false,"inventoryManagement":"SHOPIFY","inventoryPolicy":"DENY","inventoryQuantities":{"availableQuantity":0,"locationId":"gid://shopify/Location/XXX"}}]}}
{"input":{"vendor":"XXX","handle":"{uuid}","title":"XXX","descriptionHtml":"XXX\u003cbr\u003e\u003cbr\u003eXXX\u003cbr\u003e\u003cbr\u003e\u003cbr\u003e","status":"DRAFT","tags":["XXX"],"images":[{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"},{"src":"https://cdn.shopify.com/s/files/XXX.jpg"}],"variants":[{"price":1000,"compareAtPrice":1050,"taxable":false,"inventoryManagement":"SHOPIFY","inventoryPolicy":"DENY","inventoryQuantities":{"availableQuantity":0,"locationId":"gid://shopify/Location/XXX"}}]}}

Response

{"errors":[{"message":"Internal error. Looks like something went wrong on our end.\nRequest ID: 43829546-5b73-4c33-9a0e-54fc0abdef09 (include this in support requests).","extensions":{"code":"INTERNAL_SERVER_ERROR","requestId":"43829546-5b73-4c33-9a0e-54fc0abdef09"}}]}

The response error is not userErrors as shown below, but a generic error as shown above.
It is not that the bulk operation request is accepted and an error occurs after processing by shopify, but that the bulk operation request itself is not accepted in the first place.

{
    "data": {
        "bulkOperationRunMutation": {
            ...,
            "userErrors": [
                {
                    "field": [
                        "XXX"
                    ],
                    "message": "XXX"
                }
            ]
        }
    },
    ..
}

Other- The contents of “stagedUploadPath Content example” are partially masked because the actual data cannot be disclosed as is.

I have solved myself.

I converted all multibyte characters to unicode escape sequence so that all strings are ascii strings when making a request, and the request now passes for all data that was causing errors.

Example of conversion:

  • raw input: “aaaあああ +*()/^% \n”
  • Converted string: “aaa\u3042\u3042\u3042 +*()/^% \n”

See below for an example implementation in Go.

2 Likes