Skip to content

403 Forbidden Error in S3 GetObejctMetadata #3756

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
1 task
JaylenZ8 opened this issue Apr 14, 2025 · 2 comments
Closed
1 task

403 Forbidden Error in S3 GetObejctMetadata #3756

JaylenZ8 opened this issue Apr 14, 2025 · 2 comments
Labels
bug This issue is a bug.

Comments

@JaylenZ8
Copy link

JaylenZ8 commented Apr 14, 2025

Describe the bug

Hi team,

I'm using S3 SDK for .net, we started to meet 403 forbidden error recently when using GetObjectMetadata method when bucketName parameter has slash(/) in it, like "bucketName/subfolder".

Regression Issue

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

Expected Behavior

It works before when bucketName parameter has slash, like "bucketName/subfolder", any server side behavior change we need to be aware?

Current Behavior

GetMetadataObejct('bucketName/subfolder', 'keyName', null) failed with Error making request with Error Code Forbidden and Http Status Code Forbidden. No further error information was returned by the service.
The remote server returned an error: (403) Forbidden.

Reproduction Steps

Code snippet
objectMetadata = client.GetObjectMetadata(bucketName, key, null); // bucket name with slash(/) in side

Possible Solution

No response

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Package reference

   <PackageReference Update="AWSSDK.Core" Version="3.7.0.4" />
    <PackageReference Update="AWSSDK.RDS" Version="3.7.0.3" />
    <PackageReference Update="AWSSDK.S3" Version="3.7.0.4" />
    <PackageReference Update="AWSSDK.SecurityToken" Version="3.7.0.3" />

Targeted .NET Platform

.NET Framework 4.7.2

Operating System and version

Windows

@JaylenZ8 JaylenZ8 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 14, 2025
@github-actions github-actions bot added potential-regression Marking this issue as a potential regression to be checked by team member and removed potential-regression Marking this issue as a potential regression to be checked by team member labels Apr 14, 2025
@dscpinheiro
Copy link
Contributor

dscpinheiro commented Apr 14, 2025

The SDK used to (unintentionally) allow for the key prefix name to be specified as part of the bucket name, but this changed back in 2022 (see this comment for more details: #2622 (comment)).

You'll need to change your code from:

client.GetObjectMetadata("test-bucket/docs", "myfile.txt");

To:

client.GetObjectMetadata("test-bucket", "docs/myfile.txt");

@dscpinheiro dscpinheiro closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2025
Copy link

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.

@dscpinheiro dscpinheiro removed the needs-triage This issue or PR still needs to be triaged. label Apr 14, 2025
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.
Projects
None yet
Development

No branches or pull requests

2 participants