Skip to content

S3Utilities.parseUri doesn't handle region in s3-fips endpoints #6421

@Komikun

Description

@Komikun

Describe the bug

When using the S3Utilities.parseUri and passing value like:
https://myBucket.s3-fips.us-west-1.amazonaws.com/doc.txt?versionId=abc123
the region will return incorrectly.

Regression Issue

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

Expected Behavior

When providing any of the common endpoints listed here https://docs.aws.amazon.com/general/latest/gr/s3.html I expect them to be properly parsed and the region identified.
Alternatively there can be helpful error message / exception notifying me that what I am doing is not supported.

Current Behavior

The region is not identified properly.

Reproduction Steps

Slightly modifying the provided example:

S3Client s3Client = S3Client.create();
S3Utilities s3Utilities = s3Client.utilities();
String uriString = "https://myBucket.s3-fips.us-west-1.amazonaws.com/doc.txt?versionId=abc123";
URI uri = URI.create(uriString);
S3Uri s3Uri = s3Utilities.parseUri(uri);

Region region = s3Uri.region().orElse(null); // returns 'fips' instead of Region.US_WEST_1

Possible Solution

The issue is with the regex here - https://github.com/aws/aws-sdk-java-v2/blob/master/services/s3/src/main/java/software/amazon/awssdk/services/s3/S3Utilities.java

Additional Information/Context

No response

AWS Java SDK version used

2.30.19

JDK version used

openjdk version "17.0.12" 2024-07-16 LTS

Operating System and version

WIndows 11 Enterprise

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions