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

PresignedPostObject doesn't map bucket name in URL #2827

Closed
2 of 3 tasks
rdmdb opened this issue Oct 8, 2024 · 2 comments · Fixed by #2842
Closed
2 of 3 tasks

PresignedPostObject doesn't map bucket name in URL #2827

rdmdb opened this issue Oct 8, 2024 · 2 comments · Fixed by #2842
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@rdmdb
Copy link

rdmdb commented Oct 8, 2024

Acknowledgements

Describe the bug

Generating presigned URLs with PresignPostObject while using a custom BaseEndPoint and UsePathStyle set to true in the s3 config options, returns a URL that does not include the provided bucket name. This issue appears related to a similar bug in the JS counter part aws/aws-sdk-js-v3@5054ba5#diff-7253082da28c79a9309bc2a05179a34663053b1901d8724ed7f12751d5ae7ae6R90.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

The returned URL should look like <schema>://<baseendpoint>/<bucket>

Current Behavior

The returned URL is currently formatted as <schema>://<baseendpoint>

Reproduction Steps

package main

import (
	"context"
	"fmt"
	"github.com/aws/aws-sdk-go-v2/aws"
	"github.com/aws/aws-sdk-go-v2/config"
	"github.com/aws/aws-sdk-go-v2/credentials"
	"github.com/aws/aws-sdk-go-v2/service/s3"
	"time"
)

func main() {
	staticProvider := credentials.NewStaticCredentialsProvider(
		"someAccessKey",
		"someSecret",
		"",
	)
	cfg, _ := config.LoadDefaultConfig(
		context.Background(),
		config.WithCredentialsProvider(staticProvider),
		config.WithRegion("auto"),
	)
	client := s3.NewFromConfig(cfg, func(options *s3.Options) {
		options.BaseEndpoint = aws.String("https://localhost:9000")
		options.UsePathStyle = true
	})
	presignClient := s3.NewPresignClient(client)
	request, _ := presignClient.PresignPostObject(
		context.Background(),
		&s3.PutObjectInput{
			Bucket: aws.String("mybucket"),
			Key:    aws.String("myobject"),
		}, func(opts *s3.PresignPostOptions) {
			opts.Expires = time.Duration(60) * time.Second
		},
	)
	fmt.Println(request.URL) // prints https://localhost:9000
}

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

module s3issue

go 1.23.1

require (
	github.com/aws/aws-sdk-go-v2 v1.32.1
	github.com/aws/aws-sdk-go-v2/config v1.27.42
	github.com/aws/aws-sdk-go-v2/credentials v1.17.40
	github.com/aws/aws-sdk-go-v2/service/s3 v1.65.1
)

require (
	github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.16 // indirect
	github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.20 // indirect
	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.20 // indirect
	github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
	github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.20 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/sso v1.24.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.1 // indirect
	github.com/aws/aws-sdk-go-v2/service/sts v1.32.1 // indirect
	github.com/aws/smithy-go v1.22.0 // indirect
)

Compiler and Version used

go version go1.23.1 darwin/arm64

Operating System and version

macOS Sequoia Version 15.0.1

@rdmdb rdmdb added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 8, 2024
@RanVaknin RanVaknin self-assigned this Oct 8, 2024
@RanVaknin
Copy link
Contributor

Hi @rdmdb ,

I'm able to reproduce the behavior. This does seem like a bug in the implementation.

I'll add to our backlog.

Thanks,
Ran~

@RanVaknin RanVaknin added p2 This is a standard priority issue queued This issues is on the AWS team's backlog needs-review This issue or pull request needs review from a core team member. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 8, 2024
@lucix-aws lucix-aws removed the needs-review This issue or pull request needs review from a core team member. label Oct 10, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue queued This issues is on the AWS team's backlog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants