Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/ab40d3c7-4701-47ee-87f5-985d68db8b7f.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "ab40d3c7-4701-47ee-87f5-985d68db8b7f",
"type": "bugfix",
"description": "Include more information when retry strategy halts early due to token bucket capacity errors",
"issues": [
"awslabs/aws-sdk-kotlin#1321"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,8 @@ class S3ErrorMetadataIntegration : KotlinIntegration {
}
}

// SectionWriter to override the default sdkErrorMetadata and displayMetadata for S3's version
// SectionWriter to override the default sdkErrorMetadata for S3's version
private val addSdkErrorMetadataWriter = AppendingSectionWriter { writer ->
writer
.write("override val sdkErrorMetadata: S3ErrorMetadata = S3ErrorMetadata()")
.write("")
.withBlock("override val displayMetadata: List<String>", "") {
withBlock("get() =", "") {
write("super.displayMetadata + ")
write("""listOfNotNull(sdkErrorMetadata.requestId2?.let { "Extended request ID: ${'$'}it" })""")
}
}
writer.write("override val sdkErrorMetadata: S3ErrorMetadata = S3ErrorMetadata()")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ package aws.sdk.kotlin.services.s3.internal
import aws.sdk.kotlin.runtime.AwsServiceException
import aws.sdk.kotlin.services.s3.model.S3ErrorMetadata
import aws.sdk.kotlin.services.s3.model.S3Exception
import aws.smithy.kotlin.runtime.ClientErrorContext
import aws.smithy.kotlin.runtime.ErrorMetadata
import aws.smithy.kotlin.runtime.ServiceErrorMetadata
import aws.smithy.kotlin.runtime.awsprotocol.AwsErrorDetails
import aws.smithy.kotlin.runtime.awsprotocol.setAseErrorMetadata
import aws.smithy.kotlin.runtime.collections.appendValue
import aws.smithy.kotlin.runtime.collections.setIfValueNotNull
import aws.smithy.kotlin.runtime.http.response.HttpResponse
import aws.smithy.kotlin.runtime.serde.xml.data
Expand All @@ -33,12 +36,22 @@ internal data class S3ErrorDetails(
*/
internal fun setS3ErrorMetadata(exception: Any, response: HttpResponse, errorDetails: S3ErrorDetails?) {
setAseErrorMetadata(exception, response, errorDetails)

if (exception is AwsServiceException) {
exception.sdkErrorMetadata.attributes.setIfValueNotNull(ServiceErrorMetadata.RequestId, errorDetails?.requestId)
}

if (exception is S3Exception) {
val requestId2 = errorDetails?.requestId2 ?: response.headers[X_AMZN_REQUEST_ID_2_HEADER]
exception.sdkErrorMetadata.attributes.setIfValueNotNull(S3ErrorMetadata.RequestId2, requestId2)
(errorDetails?.requestId2 ?: response.headers[X_AMZN_REQUEST_ID_2_HEADER])?.let { requestId2 ->
with(exception.sdkErrorMetadata) {
attributes.setIfValueNotNull(S3ErrorMetadata.RequestId2, requestId2)

attributes.appendValue(
ErrorMetadata.ClientContext,
ClientErrorContext("Extended request ID", requestId2),
)
}
}
}
}

Expand Down
Loading