Skip to content

S3Exception when metadata value contains non-ASCII characters #2624

@cbromberg

Description

@cbromberg

S3Client throws a S3Exception with message "The request signature we calculated does not match the signature you provided. Check your key and signing method. (Service: S3, Status Code: 403..."

Expected Behavior

The documentation says Amazon S3 allows arbitrary Unicode characters in your metadata values. https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingMetadata.html
Then it goes on that you should conform to using US-ASCII, the error message says nothing with that regard (and Status Code: 403)
I would expect that the SDK would transparently encode or unencode (e.g. Unicode escape), but having the setting that is mentioned on this aws/aws-sdk-net#1587 would also be nice. Even if you leave it up to the client code it would be great to have more to the point error message.

Current Behavior

When sending the request S3Exception with message "The request signature we calculated does not match the signature you provided. Check your key and signing method..." is thrown

Possible Solution

Adapt docs, e.g. in Java the PutObjectRequestBuilder.metadata doesn't say a word about only US-ASCII, and / or guard clause to protect against non-ASCII data
Ideally a setting as mentioned in aws/aws-sdk-net#1587, as I understand you cannot change the default behaviour

Steps to Reproduce (for bugs)

@Test
void createSimpleItemWithUmlaut() {
     s3Client.putObject(PutObjectRequest.builder().bucket(TEST_BUCKET).key(System.currentTimeMillis() + "/" + "ä")
            .metadata(Map.of( "some-key", "/ä"))
            .build(), RequestBody.empty());
}

Context

Just trying to send also non-ASCII data

Your Environment

  • AWS Java SDK version used: software.amazon.awssdk:s3:2.16.6
  • JDK version used: openjdk 11.06
  • Operating System and version: MacOS 11.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-for-stalenessservice-apiThis issue is due to a problem in a service API, not the SDK implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions