Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing ETag from S3 UploadPart response #1362

Open
2 tasks done
madsborup opened this issue Jan 24, 2025 · 13 comments
Open
2 tasks done

Missing ETag from S3 UploadPart response #1362

madsborup opened this issue Jan 24, 2025 · 13 comments
Labels
bug Something isn't working

Comments

@madsborup
Copy link

madsborup commented Jan 24, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Similar to aws/aws-sdk-js-v3#5708

I'm trying to implement MultiPartUpload using the AWS S3 client, but the response object of UploadPart does not include the ETag property, though it's included in the HTTP response. I suspect this may be due to ETag header not allowed in CORS settings (as mentioned in the above similar issue).

To Reproduce

const client = new S3Client({
  forcePathStyle: true,
  region: "eu-central-1",
  endpoint: "https://....supabase.co/storage/v1/s3",
  credentials: {
    accessKeyId: "...",
    secretAccessKey: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
    sessionToken: userSession.access_token,
  },
});

const uploadPartResponse = await client.send(
  new UploadPartCommand({
    Bucket: BUCKET_NAME,
    Key: key,
    PartNumber: partNumber,
    UploadId: uploadId,
    Body: chunk,
  })
);

Expected behavior

ETag property should be present in uploadPartResponse object.

Screenshots

Image Image

System information

  • OS: macOS
  • @supabase/supabase-js: ^2.48.1
  • @aws-sdk/client-s3: ^3.733.0
@madsborup madsborup added the bug Something isn't working label Jan 24, 2025
@Rudra-Sankha-Sinhamahapatra

@madsborup are you working on this issue?

@cboycecollab
Copy link

Same here! I am experiencing the same thing. Whether using the Upload functionality from @aws-sdk/lib-storage or just using the aws-sdk/client-s3 everything works fine except that the ETag is not being propagated back to the code so the uploads will never complete.

@cboycecollab
Copy link

@madsborup Are you currently working on this issue?

@madsborup
Copy link
Author

@cboycecollab No, I contacted support but haven't received any updates...

@cboycecollab
Copy link

@madsborup Okay no worries, I honestly surprised that nobody else has mentioned this as an issue. It makes the S3 functionality useless from when uploading from the front-end

@fenos
Copy link
Contributor

fenos commented Feb 14, 2025

Hello, guys i'm looking into this

@fenos
Copy link
Contributor

fenos commented Feb 14, 2025

By the first look, it seems that we have a test covering this.
https://github.com/supabase/storage/blob/master/src/test/s3-protocol.test.ts#L475

however, I'm digging deeper

@fenos
Copy link
Contributor

fenos commented Feb 14, 2025

Got it, i believe the issue is at the cloudflare level, where the etag is getting modified / removed.
I'll be looking into adding a page rule for the S3 endpoint to allow cloudflare to pass the correct etag on this operation.

Stay tuned

@cboycecollab
Copy link

@fenos you are the goat thank you for looking into this. I am curious though, how did you come to the conclusion that it was an issue at the cloudflare level? Additionally, from what you've been able to uncover, does there seem to be any immediate workarounds?

@fenos
Copy link
Contributor

fenos commented Feb 14, 2025

The test is passing locally regarding the Etag, as I was debugging it locally I couldn't find anything wrong with it.

However, I had a couple of instances where cloudflare was changing the request to storage and I had to patch it with custom page rules.

after reading how they handle etags in headers it looks like they are issue, which can be disabled.

We use cloudflare in front of storage at the moment hence is very likely this is the issue.

I'll send a patch sometimes next week 👍🏻

@cboycecollab
Copy link

Really appreciate it dude! Yeah the upload worked fine as long as there was only one chunk in the upload but as soon as there was multiple chunks it started screaming about the ETag.

@cboycecollab
Copy link

@fenos please let me know when / if you get a chance to submit a PR for this!

@SouthCentralCode
Copy link

hey,

I'm getting the exact same issue of etag not being accessible in the headers of the response within a react js component, however this is occurring for me on the local docker supabase instance i'm testing with.

I am using signedUrl instead of the s3 client as i am working client-side, but getting the signed url via an api call to the server.

The signedUrl functionality is working as expected for the other multipart related calls.

Assuming this is a CORS issue on my local instance, i'm struggling on how i can override the CORS setting anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants