Skip to content

Commit 6c2a39b

Browse files
committed
fix: changelog and last bit of feedback
1 parent 8f65c72 commit 6c2a39b

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "3339e5cc-978c-4941-a975-6c0c82d6426f",
3+
"type": "feature",
4+
"description": "S3 client behavior is updated to always calculate a checksum by default for operations that support it (such as PutObject or UploadPart), or require it (such as DeleteObjects). The checksum algorithm used by default varies by SDK (CRC32 or CRC64, CRC32 for the Kotlin SDK). Checksum calculation behavior can be configured using `when_supported` and `when_required` options - in code using requestChecksumCalculation, in shared config using request_checksum_calculation, or as env variable using AWS_REQUEST_CHECKSUM_CALCULATION. The S3 client attempts to validate response checksums for all S3 API operations that support checksums. However, if the SDK has not implemented the specified checksum algorithm then this validation is skipped. Checksum validation behavior can be configured using `when_supported` and `when_required` options - in code using responseChecksumValidation, in shared config using response_checksum_validation, or as env variable using AWS_RESPONSE_CHECKSUM_VALIDATION."
5+
}

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,30 @@ public val AwsProfile.sigV4aSigningRegionSet: String?
174174
*/
175175
@InternalSdkApi
176176
public val AwsProfile.requestChecksumCalculation: RequestHttpChecksumConfig?
177-
get() = getOrNull("request_checksum_calculation")?.parseRequestHttpChecksumConfig()
177+
get() = getOrNull("request_checksum_calculation")?.run {
178+
RequestHttpChecksumConfig
179+
.values()
180+
.firstOrNull { it.name.equals(this, ignoreCase = true) }
181+
?: throw ConfigurationException(
182+
"request_checksum_calculation $this is not supported, should be one of: " +
183+
RequestHttpChecksumConfig.values().joinToString(", ") { it.name.lowercase() },
184+
)
185+
}
178186

179187
/**
180188
* Configures response checksum validation
181189
*/
182190
@InternalSdkApi
183191
public val AwsProfile.responseChecksumValidation: ResponseHttpChecksumConfig?
184-
get() = getOrNull("response_checksum_validation")?.parseResponseHttpChecksumConfig()
192+
get() = getOrNull("response_checksum_validation")?.run {
193+
ResponseHttpChecksumConfig
194+
.values()
195+
.firstOrNull { it.name.equals(this, ignoreCase = true) }
196+
?: throw ConfigurationException(
197+
"response_checksum_validation $this is not supported, should be one of: " +
198+
ResponseHttpChecksumConfig.values().joinToString(", ") { it.name.lowercase() },
199+
)
200+
}
185201

186202
/**
187203
* Parse a config value as a boolean, ignoring case.
@@ -216,32 +232,6 @@ public fun AwsProfile.getLongOrNull(key: String, subKey: String? = null): Long?
216232
)
217233
}
218234

219-
/**
220-
* Parse a string value as [ResponseHttpChecksumConfig]
221-
*/
222-
private fun String?.parseResponseHttpChecksumConfig(): ResponseHttpChecksumConfig? =
223-
when (this?.uppercase()) {
224-
null -> null
225-
"WHEN_SUPPORTED" -> ResponseHttpChecksumConfig.WHEN_SUPPORTED
226-
"WHEN_REQUIRED" -> ResponseHttpChecksumConfig.WHEN_REQUIRED
227-
else -> throw ConfigurationException(
228-
"'$this' is not a valid value for 'response_checksum_validation'. Valid values are: ${ResponseHttpChecksumConfig.entries}",
229-
)
230-
}
231-
232-
/**
233-
* Parse a string value as [RequestHttpChecksumConfig]
234-
*/
235-
private fun String?.parseRequestHttpChecksumConfig(): RequestHttpChecksumConfig? =
236-
when (this?.uppercase()) {
237-
null -> null
238-
"WHEN_SUPPORTED" -> RequestHttpChecksumConfig.WHEN_SUPPORTED
239-
"WHEN_REQUIRED" -> RequestHttpChecksumConfig.WHEN_REQUIRED
240-
else -> throw ConfigurationException(
241-
"'$this' is not a valid value for 'request_checksum_calculation'. Valid values are: ${RequestHttpChecksumConfig.entries}",
242-
)
243-
}
244-
245235
internal fun AwsProfile.getUrlOrNull(key: String, subKey: String? = null): Url? =
246236
getOrNull(key, subKey)?.let {
247237
try {

aws-runtime/aws-http/api/aws-http.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public final class aws/sdk/kotlin/runtime/http/interceptors/BusinessMetricsInter
198198

199199
public final class aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexibleChecksumResponseInterceptor : aws/smithy/kotlin/runtime/http/interceptors/FlexibleChecksumsResponseInterceptor {
200200
public fun <init> (ZLaws/smithy/kotlin/runtime/client/config/ResponseHttpChecksumConfig;)V
201-
public fun ignoreChecksum (Ljava/lang/String;Laws/smithy/kotlin/runtime/telemetry/logging/Logger;)Z
201+
public fun ignoreChecksum (Ljava/lang/String;Laws/smithy/kotlin/runtime/client/ProtocolResponseInterceptorContext;)Z
202202
}
203203

204204
public final class aws/sdk/kotlin/runtime/http/interceptors/UnsupportedSigningAlgorithmInterceptor : aws/smithy/kotlin/runtime/client/Interceptor {

aws-runtime/aws-http/common/src/aws/sdk/kotlin/runtime/http/interceptors/IgnoreCompositeFlexibleChecksumResponseInterceptor.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package aws.sdk.kotlin.runtime.http.interceptors
22

3+
import aws.smithy.kotlin.runtime.client.ProtocolResponseInterceptorContext
34
import aws.smithy.kotlin.runtime.client.config.ResponseHttpChecksumConfig
45
import aws.smithy.kotlin.runtime.http.interceptors.FlexibleChecksumsResponseInterceptor
5-
import aws.smithy.kotlin.runtime.telemetry.logging.Logger
6+
import aws.smithy.kotlin.runtime.http.request.HttpRequest
7+
import aws.smithy.kotlin.runtime.http.response.HttpResponse
8+
import aws.smithy.kotlin.runtime.telemetry.logging.info
69

710
/**
811
* Variant of the [FlexibleChecksumsResponseInterceptor] where composite checksums are not validated
@@ -14,9 +17,16 @@ public class IgnoreCompositeFlexibleChecksumResponseInterceptor(
1417
responseValidationRequired,
1518
responseChecksumValidation,
1619
) {
17-
override fun ignoreChecksum(checksum: String, logger: Logger): Boolean =
20+
override fun ignoreChecksum(
21+
checksum: String,
22+
context: ProtocolResponseInterceptorContext<Any, HttpRequest, HttpResponse>,
23+
): Boolean =
1824
checksum.isCompositeChecksum().also { compositeChecksum ->
19-
if (compositeChecksum) logger.info { "Checksum validation was skipped because it was a composite checksum" }
25+
if (compositeChecksum) {
26+
context.executionContext.coroutineContext.info<IgnoreCompositeFlexibleChecksumResponseInterceptor> {
27+
"Checksum validation was skipped because it was a composite checksum"
28+
}
29+
}
2030
}
2131
}
2232

0 commit comments

Comments
 (0)