Closed lauzadis closed 3 months ago
A new generated diff is ready to view.
question: do S3s 403 responses frequently contain payloads? I think we would still fail with the same
Failed to parse response as ...
exception if that's the case
HeadObject 403 never contains a payload. Here is a sample codegen:
private fun throwHeadObjectError(context: ExecutionContext, call: HttpCall, payload: ByteArray?): kotlin.Nothing {
val wrappedResponse = call.response.withPayload(payload)
val wrappedCall = call.copy(response = wrappedResponse)
val errorDetails = try {
if (payload == null) {
if (call.response.status == HttpStatusCode.NotFound) {
S3ErrorDetails(code = "NotFound")
} else {
S3ErrorDetails(code = call.response.status.toString())
}
} else {
checkNotNull(payload) { "unable to parse error from empty response" }
parseS3ErrorResponse(payload)
}
} catch (ex: Exception) {
throw S3Exception("Failed to parse response as restXml").also {
setS3ErrorMetadata(it, wrappedCall.response, null)
}
}
val ex = when(errorDetails.code) {
"NotFound" -> NotFoundDeserializer().deserialize(context, wrappedCall, payload)
else -> S3Exception(errorDetails.message)
}
setS3ErrorMetadata(ex, wrappedResponse, errorDetails)
throw ex
}
I'm not sure how a 403 with a non-null payload will get an Failed to parse response as restXml error
exception thrown unless it's malformed.
A new generated diff is ready to view.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
A new generated diff is ready to view.
Previously we only checked for empty bodies with HTTP 404, but it seems like S3 also returns empty bodies for HTTP 403. This PR expands the handler logic to catch all empty bodies rather than just 404's.
Issue \
Closes https://github.com/awslabs/aws-sdk-kotlin/issues/1368
Description of changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.