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

Golang aws sdk v2 cannot upload to supabase storage #577

Open
2 tasks done
hmhuan opened this issue Oct 24, 2024 · 11 comments
Open
2 tasks done

Golang aws sdk v2 cannot upload to supabase storage #577

hmhuan opened this issue Oct 24, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@hmhuan
Copy link

hmhuan commented Oct 24, 2024

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

I got issue while using golang aws sdk v2 (github.com/aws/aws-sdk-go-v2) to integrate with supabase storage. The document said I should check again the error SignatureDoesNotMatch but I set access key id / access secret key / region that are all correct

operation error S3: PutObject, https response error StatusCode: 403, RequestID: , HostID: , api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to '…'
  2. Click on '…'
  3. Scroll down to '…'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • Version of Go go 1.22.0

Additional context

Add any other context about the problem here.

@hmhuan hmhuan added the bug Something isn't working label Oct 24, 2024
@hmhuan
Copy link
Author

hmhuan commented Oct 25, 2024

I try to use Golang aws sdk v1, and I could upload object normally

@encima
Copy link
Member

encima commented Oct 25, 2024

Hi there, thanks for opening. We cannot guarantee compatibility across all SDKs and libraries that support S3, thanks for reporting that v1 does work and that v2 does not!

For now, I would suggest using v1 if possible!

@encima encima transferred this issue from supabase/supabase Oct 25, 2024
@mercuryyy
Copy link

@encima the issue is livekit pushed a mandatory change to v2 and so have others lately and we can not revert back to v1

#569

Can your team possibly take a look and see if this can be updated to support v2 ?

@fenos
Copy link
Contributor

fenos commented Oct 29, 2024

Hello the issue seems related to the new go SDK, I'll open an issue on their end and see what they think.

For now a workaround that seem to work, is to remove the DisableAcceptEncodingGzip middleware which is on by default in the new SDK

func removeDisableGzip() func(*middleware.Stack) error {
	return func(stack *middleware.Stack) error {
		_, err := stack.Finalize.Remove("DisableAcceptEncodingGzip")
		return err
	}
}

func main() {
	ctx := context.Background()

	endpoint := "https://tenant.supabase.co/storage/v1/s3"
	accessKeyId := ""
	secretAccessKey := ""
	region := "ap-southeast-1"

	sdkConfig := aws.Config{
		Region:       region,
		BaseEndpoint: &endpoint,
		Credentials:  credentials.NewStaticCredentialsProvider(accessKeyId, secretAccessKey, ""),
		APIOptions:  []func(*middleware.Stack) error{removeDisableGzip()},
	}

	s3Client := s3.NewFromConfig(sdkConfig)
	
	result, err := s3Client.ListBuckets(ctx, &s3.ListBucketsInput{})
}

@fenos
Copy link
Contributor

fenos commented Oct 29, 2024

Related aws/aws-sdk-go-v2#2848

@hmhuan
Copy link
Author

hmhuan commented Oct 29, 2024

Thanks for your sharing

@frostbyte73
Copy link

I'm hesitant to use the workaround, since we don't know which provider(s) our end users are using or whether that would break compatibility with those. V1 is also deprecated and we started seeing other issues with it, so staying on it isn't really an option

https://aws.amazon.com/blogs/developer/announcing-end-of-support-for-aws-sdk-for-go-v1-on-july-31-2025/

@ramikalai
Copy link

Would be great to get support for V2. Livekit uses this and therefore is now not compatible with Supabase storage. I'm sure lots of other services will be migrating and this will become more of a compatibility issue.

@SwarmStorm
Copy link

Confirmed on my end with Supabase as well, and am getting the same problem

@pi0
Copy link

pi0 commented Dec 18, 2024

Hi there. We recently introduced s3 driver for unstorage (used by Nuxt, Nitro and more frameworks!) and was curious if we can support/document Supabase out of the box.

I ran our tests against a superbase sandbox and hit this issue. (implementation uses aws4fetch).

@a29paul
Copy link

a29paul commented Jan 4, 2025

Getting the same issue when using with Livekit. Have to now explore an alternative solution, but would be great to have this fixed. Goal of using Supabase for me is that I don't need to use a bunch of other services, so if we can fix this issue, I'd be able to consolidate which would be awesome.

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

9 participants