S3 GetBucketLocation does not correctly parse errors
ianbotsf opened this issue · comments
Describe the bug
The S3 GetBucketLocation
operation does not correctly parse errors when the response contains them.
Expected behavior
Calling GetBucketLocation
and getting an error back in the response should lead to that error being properly deserialized into a modeled exception (e.g., calling the API for a non-existent bucket should yield a NotFound
or S3Exception
).
Current behavior
An error in the GetBucketLocation
response will cause a generic parsing error:
Exception in thread "main" java.lang.IllegalStateException: Expected top-level tag of 'LocationConstraint' but found Error.
at aws.sdk.kotlin.services.s3.internal.GetBucketLocationOperationDeserializerKt.deserializeGetBucketLocationOperationBody(GetBucketLocationOperationDeserializer.kt:37)
at aws.sdk.kotlin.services.s3.internal.GetBucketLocationOperationDeserializerKt.access$deserializeGetBucketLocationOperationBody(GetBucketLocationOperationDeserializer.kt:1)
at aws.sdk.kotlin.services.s3.internal.GetBucketLocationOperationDeserializer.deserialize(GetBucketLocationOperationDeserializer.kt:29)
at aws.sdk.kotlin.services.s3.internal.GetBucketLocationOperationDeserializer$deserialize$1.invokeSuspend(GetBucketLocationOperationDeserializer.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
at foo.ScratchKt.main(Scratch.kt:17)
at foo.ScratchKt.main(Scratch.kt)
Steps to Reproduce
val s3 = S3Client.fromEnvironment()
s3.getBucketLocation { bucket = "some-bucket-that-does-not-exist" }
Possible Solution
The deserializer for this API is handwritten but does not check for HTTP error codes before attempting to deserialize. This doesn't match how we codegen deserializers. We should either update the handwritten code or find a way to customize our codegen for atypical APIs like GetBucketLocation
.
Context
No response
AWS Kotlin SDK version used
v0.27.2-beta
Platform (JVM/JS/Native)
OpenJDK 8
Operating System and version
Amazon Linux 2