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.
- The descriptionHTML may contain Japanese strings and html tags. html tags are used only for
and, and no other tags are included.
- The html tags in JSONL are requested with escaping. We have also tried requesting without escaping, but have encountered the same problem (some data will pass the request, but some data will not).
- Problems that may be similar