Re: Error uploading file after stagedUploadsCreate

Solved

Error uploading file after stagedUploadsCreate

Mickeydtails
Shopify Partner
9 1 7

Hi fellow developers,

 

I’m experiencing a very strange issue in the Shopify GraphQL API, specifically it’s when trying to upload a file prepared by the stagedUploadsCreate endpoint for running a bulk mutation query.

 

The flow is like this:

  1. Create file with bulk product input
  2. Run file through “stagedUploadsCreate” endpoint
  3. I get a valid response and then prepare and send using stagedUpload.stagedUploadsCreate.stagedTargets[0]
  4. Send file using POST request with file included as a multipart/form-data, including auth headers etc.
  5. After a looong time I get the following error returned “Error: Internal error. Looks like something went wrong on our end. Request ID: 8752b130-2cbb-41aa-a746-6288ceaa5820 (include this in support requests).” (Of course the Request ID is different from time to time)

 

The funny thing is that it works on another Shopify instance. Both instances are running Shopify markets with pretty much the same configuration. The code running the “stagedUploadsCreate” and upload of the file is 100% identical, it’s the same backend just using different Shopify API endpoints and keys (Shopify API Version is the same for calling both stores)

 

I’ve thoroughly debugged the API output from both Shopify stores and I’ve spotted a difference, and that is the upload endpoint returned by “stagedUploadsCreate”. On the store where it works the upload endpoint URL is https://shopify.s3.amazonaws.com/ but on the store where it does not work the upload endpoint URL is http://shopify-staged-uploads.storage.googleapis.com/ . Two questions arises from this: Why is there a difference between the store endpoints, are some stores using AWS and others Google Cloud? And why is the Google Cloud endpoint not functioning?

 

Note that it has previously worked on the store where it’s not working today.

 

This is quite urgent as we’re about to go live with the two stores and not being able to use the bulk mutation API breaks a lot of the required functionality

 

Thanks,

Mickey

 

Accepted Solutions (2)

BrandBoosting
Shopify Partner
4 1 4

This is an accepted solution.

This bug seems to be resolved for us. Can you confirm @Mickeydtails ?

Shopify Agentur auf höchstem Niveau

View solution in original post

Mickeydtails
Shopify Partner
9 1 7

This is an accepted solution.

Got it working again, found out it was something in the code causing this issue. On AWS it worked, but not on Google. Specifically it was the "Content-Length" header when uploading the bulk file

 

const response = await axios.post(url, form, {
    headers: {
      'Content-Type' : 'multipart/form-data',
      ...form.getHeaders(),
      "Content-Length": fileSize + 5000, 
    },
  });

 Removing the "Content-Length" entirely makes it work. Note that I've not tested if it still works on API's hitting the AWS servers

View solution in original post

Replies 11 (11)

BrandBoosting
Shopify Partner
4 1 4

We are currently experiencing the same weird bug. Is Shopify in the midst of migrating from S3 to Google Cloud Storage?

Shopify Agentur auf höchstem Niveau

Khaled_Elabd
Shopify Partner
1 0 1

We are having the exact same issue, it started yesterday and before this, it was working just fine.
Can someone from the Shopify team help with this please as this is so urgent for us?

BrandBoosting
Shopify Partner
4 1 4

Jan Gregor from the Developer Advocacy Team was made aware of the issue and forwarded it to Ops.

https://app.slack.com/client/T4BB7S7HP/C4E5GV5U4/thread/C4E5GV5U4-1661888088.376179

Shopify Agentur auf höchstem Niveau
Jean-CharlesBAL
Visitor
1 0 0

Is it a public Slack? The workspace name is needed to connect.

Can you provide a way to follow this discussion?

 

For the issue, same problem here, upload to AWS looks replaced by upload to GCP.

If this is permanent it would be nice to update the documentation here:

https://shopify.dev/api/usage/bulk-operations/imports#upload-the-file-to-shopify

BrandBoosting
Shopify Partner
4 1 4

The Slack should by accessible via
https://www.delightchat.io/ecommerce-forums-facebook-groups/shopify-partners-slack-community

Shopify Agentur auf höchstem Niveau

BrandBoosting
Shopify Partner
4 1 4

This is an accepted solution.

This bug seems to be resolved for us. Can you confirm @Mickeydtails ?

Shopify Agentur auf höchstem Niveau
Mickeydtails
Shopify Partner
9 1 7

Yes I can confirm that it works again now. I tested on two different stores having the same issue, both works again. Wuhuu 🙂 

Mickeydtails
Shopify Partner
9 1 7

Not working again now, seems like the exact same issue as before. Endpoint Url is back to http://shopify-staged-uploads.storage.googleapis.com/

Mickeydtails
Shopify Partner
9 1 7

This is an accepted solution.

Got it working again, found out it was something in the code causing this issue. On AWS it worked, but not on Google. Specifically it was the "Content-Length" header when uploading the bulk file

 

const response = await axios.post(url, form, {
    headers: {
      'Content-Type' : 'multipart/form-data',
      ...form.getHeaders(),
      "Content-Length": fileSize + 5000, 
    },
  });

 Removing the "Content-Length" entirely makes it work. Note that I've not tested if it still works on API's hitting the AWS servers

Yusuke10
Shopify Partner
2 0 0

Does this problem occur often?
When I try to upload an image in Ruby on rails, I get the following error

 

Failed to open TCP connection to shopify-staged-uploads.storage.googleapis.com:443 (execution expired)

 

It was working fine until a few days ago, so we believe the trigger of the problem is in Google cloud.

dipanshu_1009
Shopify Partner
2 0 0

Is this resolved? I am facing the same issue.

Attaching the curls if anyone can help me out.

 

for stagedUploadImage:

return await axiosGQL({
data: {
query: `mutation generateStagedUploads {
stagedUploadsCreate(input: [
{
filename: "${image.name}",
mimeType: "${image.type}",
resource: IMAGE,
fileSize: "${image.size}",
},
])
{
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
userErrors {
field, message
}
}
}
`,
}
})

 

for uploading:

"curl --location --request PUT 'https://shopify-staged-uploads.storage.googleapis.com/tmp/67265462582/products/30f0290e-aa18-4b01-84...' \
--header 'Content-Length: 8671' \
--header 'acl: private' \
--header 'content_type: image/png' \
--form 'file=@"/C:/Users/SAURAV SINGH RAUTHAN/Downloads/sizeChart.png"