Skip to content

SDK stopped supporting specifying S3 key path in bucket name property #3021

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

Closed
wr-cdargis opened this issue Aug 7, 2023 · 3 comments
Closed
Labels
bug This issue is a bug. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. s3

Comments

@wr-cdargis
Copy link

Describe the bug

We've been using similar code at times to upload to S3. We are specifying the path to the object as part of the bucket name:

using (AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USEast1))
{
    PutObjectRequest request = new PutObjectRequest
    {
        BucketName = "my-bucket/path/to/my/object",
        Key = "my-object.txt"
    };
    PutObjectResponse response = await client.PutObjectAsync(request);
}

The above snippet worked. Once we upgraded to AWSSDK.S3 3.7.104.26, AWSSDK.Core 3.7.107 (I believe it's actually the Core version that dropped the support somehow) we started getting this exception:

Amazon.S3.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method.

I have confirmed that switching the code to the following works:

using (AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USEast1))
{
    PutObjectRequest request = new PutObjectRequest
    {
        BucketName = "my-bucket",
        Key = "path/to/my/object/my-object.txt"
    };
    PutObjectResponse response = await client.PutObjectAsync(request);
}

I am hoping there is a different workaround that doesn't involve scouring our large codebase. Is it possible to get this fixed and supported again?

Expected Behavior

The request to succeed as is has in previous versions of the SDK.

Current Behavior

The client throws this exception

Amazon.S3.AmazonS3Exception: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Reproduction Steps

using (AmazonS3Client client = new AmazonS3Client(RegionEndpoint.USEast1))
{
    PutObjectRequest request = new PutObjectRequest
    {
        BucketName = "my-bucket",
        Key = "path/to/my/object/my-object.txt"
    };
    PutObjectResponse response = await client.PutObjectAsync(request);
}

Possible Solution

No response

Additional Information/Context

I know that current documentation doesn't suggest constructing the upload request this way. I don't know if this was ever purposefully supported.

AWS .NET SDK and/or Package version used

Specifying path in bucket name works in this version and previous:
AWSSDK.S3 3.7.104.25
AWSSDK.Core 3.7.106.45

Specifying the path breaks in this Core version:
AWSSDK.S3 3.7.104.26
AWSSDK.Core 3.7.107

The request will fail if I specify AWSSDK.S3 3.7.104.25 w/ Core version 3.7.107.

Targeted .NET Platform

.NET 6, .NET Framework 4.7.2

Operating System and version

Windows 10

@wr-cdargis wr-cdargis added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2023
@ashishdhingra
Copy link
Contributor

Hi @wr-cdargis,

Good morning.

Thanks for reporting the issue. Please refer #2622 (comment) for the reasoning why SDK stopped supporting specifying key path as part of bucket name. The support was removed in commit 33bfebe. As mentioned, it was never intended to pass in a key prefix as part of the BucketName property and that working in the past was an accidental side affect. Bucket name per https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html should only contain name of bucket whereas Key could contain path elements per example at the above documentation.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2023
@wr-cdargis
Copy link
Author

Ah ok. Thank you!

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. s3
Projects
None yet
Development

No branches or pull requests

2 participants