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

PutObjectRequest metadata with non ASCII characters will fail to set OkHttp Headers #1163

Closed
tylerjroach opened this issue Dec 22, 2023 · 2 comments
Assignees
Labels
bug This issue is a bug.

Comments

@tylerjroach
Copy link

Describe the bug

If PubObjectRequest (likely all other storage request types) metadata contains non-ASCII characters in a header pair, the request will fail.

OkHttp does not accept non-ASCII characters by default and requires adding flag for leniency or https://square.github.io/okhttp/5.x/okhttp/okhttp3/-headers/-builder/add-unsafe-non-ascii.html.

DefaultS3Client appears to use the default OkHttp config not allowing non-ASCII header values.

See report from Amplify v2 for more info: aws-amplify/amplify-android#2657

Expected behavior

Allow non-ASCII characters in header values.

Current behavior

Request never attempted.

Caused by: java.lang.IllegalArgumentException: Unexpected char 0xd83d at 0 in x-amz-meta-custom value: 😏
	at okhttp3.internal._HeadersCommonKt.headersCheckValue(-HeadersCommon.kt:140)
	at okhttp3.internal._HeadersCommonKt.commonAdd(-HeadersCommon.kt:77)
	at okhttp3.Headers$Builder.add(Headers.kt:166)
	at okhttp3.internal._RequestCommonKt.commonAddHeader(-RequestCommon.kt:60)
	at okhttp3.Request$Builder.addHeader(Request.kt:221)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpUtilsKt$toOkHttpRequest$1.invoke(OkHttpUtils.kt:54)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpUtilsKt$toOkHttpRequest$1.invoke(OkHttpUtils.kt:52)
	at aws.smithy.kotlin.runtime.util.ValuesMap$DefaultImpls.forEach(ValuesMap.kt:54)
	at aws.smithy.kotlin.runtime.util.ValuesMapImpl.forEach(ValuesMap.kt:69)
	at aws.smithy.kotlin.runtime.http.engine.okhttp.OkHttpUtilsKt.toOkHttpRequest(OkHttpUtils.kt:52)

Steps to Reproduce

Initiate:

PutObjectRequest {
  ...
  metadata = mapOf("custom" to "😏")
  ...
}

execute request

Possible Solution

No response

Context

No response

AWS Kotlin SDK version used

All

Platform (JVM/JS/Native)

JVM

Operating System and version

Android

@tylerjroach tylerjroach added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 22, 2023
@lauzadis lauzadis self-assigned this Dec 27, 2023
@lauzadis lauzadis removed the needs-triage This issue or PR still needs to be triaged. label Dec 27, 2023
@ianbotsf
Copy link
Contributor

Resolved by smithy-lang/smithy-kotlin#1019

Copy link

⚠️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.
Projects
None yet
Development

No branches or pull requests

3 participants