aws-sdk-kotlin
aws-sdk-kotlin copied to clipboard
301 response from S3 causes UnknownServiceErrorException
Describe the bug
When an service returns a 301 w/ no body, the client throws a UnknownServiceErrorException.
Expected Behavior
Some error that accurately conveys the meaning of a 301 should be returned to the caller.
Current Behavior
Sample stack trace:
Exception in thread "main" aws.sdk.kotlin.runtime.UnknownServiceErrorException: failed to parse response as Xml protocol error
at aws.sdk.kotlin.service.s3.internal.S3ErrorFeature$install$1.invokeSuspend(S3ErrorFeature.kt:86)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:142)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
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 com.example.s3.S3ObjectOperations.main(Test.kt:51)
Caused by: java.io.EOFException: input contained no data
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3003)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at aws.smithy.kotlin.runtime.serde.xml.XmlStreamReaderXmlPull.takeNextValidToken(XmlStreamReaderXmlPull.kt:127)
at aws.smithy.kotlin.runtime.serde.xml.XmlStreamReaderXmlPull.<init>(XmlStreamReaderXmlPull.kt:37)
at aws.smithy.kotlin.runtime.serde.xml.XmlStreamReaderXmlPull.<init>(XmlStreamReaderXmlPull.kt:21)
at aws.smithy.kotlin.runtime.serde.xml.XmlStreamReaderXmlPullKt.xmlStreamReader(XmlStreamReaderXmlPull.kt:19)
at aws.smithy.kotlin.runtime.serde.xml.XmlDeserializer.<init>(XmlDeserializer.kt:34)
at aws.sdk.kotlin.service.s3.internal.S3ErrorFeatureKt.parseErrorResponse(S3ErrorFeature.kt:147)
at aws.sdk.kotlin.service.s3.internal.S3ErrorFeature$install$1.invokeSuspend(S3ErrorFeature.kt:83)
... 12 more
Steps to Reproduce
- create a bucket
- call
s3.headBucket()
Possible Solution
Return an exception type more specific to the 3xx error type