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

S3Utilities.parseUri(): support unencoded URI #3955

Open
dmoini opened this issue Apr 26, 2023 · 3 comments
Open

S3Utilities.parseUri(): support unencoded URI #3955

dmoini opened this issue Apr 26, 2023 · 3 comments
Labels
feature-request A feature should be added or improved.

Comments

@dmoini
Copy link

dmoini commented Apr 26, 2023

Describe the bug

I currently have an S3 object with the S3 URI s3://test-bucket/test file with spaces. When I attempt to create an S3Uri object with the parseUri() method (code), I receive the following exception:

// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))

// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
    at java.net.URI$Parser.fail (:-1) 
    at java.net.URI$Parser.checkChars (:-1) 
    at java.net.URI$Parser.parseHierarchical (:-1)

This is due to the URI constructor, specifically because it does not allow input strings to have spaces in them. However, valid S3 URIs can contain spaces in them.

Expected Behavior

// Code
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))
println(s3Uri) // S3Uri(uri=s3://test-bucket/test file with spaces, bucket=test-bucket, key=test file with spaces, isPathStyle=false, queryParams={})

Current Behavior

// Code with S3 client from v2 SDK
val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))

// Exception
Caused by: java.net.URISyntaxException: Illegal character in path at index 21: s3://test-bucket/test file with spaces
    at java.net.URI$Parser.fail (:-1) 
    at java.net.URI$Parser.checkChars (:-1) 
    at java.net.URI$Parser.parseHierarchical (:-1)

Reproduction Steps

val s3Uri = s3Client.utilities().parseUri(URI("s3://test-bucket/test file with spaces"))

Possible Solution

No response

Additional Information/Context

No response

AWS Java SDK version used

2.0

JDK version used

8

Operating System and version

macOS 12.6.5

@dmoini dmoini added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 26, 2023
@dmoini dmoini changed the title S3Utilities.parseUri() unable to parse S3 path where key name has spaces S3Utilities.parseUri() throws excetion when S3 URI has key name with spaces Apr 26, 2023
@dmoini
Copy link
Author

dmoini commented Apr 26, 2023

I have learned that this is intentional. To work around this issue, you just need to replace all space characters with %20. Closing this issue.

@dmoini dmoini closed this as completed Apr 26, 2023
@zoewangg zoewangg added feature-request A feature should be added or improved. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 26, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@zoewangg zoewangg changed the title S3Utilities.parseUri() throws excetion when S3 URI has key name with spaces S3Utilities.parseUri(): support unencoded URI Apr 26, 2023
@zoewangg
Copy link
Contributor

Re-open this issue to support unencoded String in S3Utilities.parseUri

@zoewangg zoewangg reopened this Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

2 participants