Skip to content

Commit e7e342d

Browse files
xinsong-cuilauzadisaws-sdk-kotlin-ciianbotsf
authored
v1.5 merge (#1232)
* fix: add 0.9.x aws-crt-kotlin transform (#1220) * fix: Ensure `Host` header is included when signing auth tokens (#1222) * chore: release 1.4.1 * chore: bump snapshot version to 1.4.2-SNAPSHOT * fix: address various failing protocol tests (#1223) * misc: re-enable `kotlinWarningsAsErrors=true` (#1224) * fix: ignore hop-by-hop headers when signing requests (#1227) * chore: release 1.4.2 * chore: bump snapshot version to 1.4.3-SNAPSHOT * misc: add telemetry configuration to DefaultAwsSigner (#1226) * add telemetry provider configuration * lint * address pr reviews * add changelog --------- Co-authored-by: Matas <[email protected]> Co-authored-by: aws-sdk-kotlin-ci <[email protected]> Co-authored-by: Ian Botsford <[email protected]>
1 parent 2e44922 commit e7e342d

File tree

28 files changed

+171
-91
lines changed

28 files changed

+171
-91
lines changed

.brazil.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"com.squareup.okio:okio-jvm:3.*": "OkioJvm-3.x",
99
"io.opentelemetry:opentelemetry-api:1.*": "Maven-io-opentelemetry_opentelemetry-api-1.x",
1010
"org.slf4j:slf4j-api:2.*": "Maven-org-slf4j_slf4j-api-2.x",
11+
"aws.sdk.kotlin.crt:aws-crt-kotlin:0.9.*": "AwsCrtKotlin-0.9.x",
1112
"aws.sdk.kotlin.crt:aws-crt-kotlin:0.8.*": "AwsCrtKotlin-0.8.x",
1213
"com.squareup.okhttp3:okhttp:4.*": "OkHttp3-4.x"
1314
},
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"id": "d3ce7511-6fb2-4435-8f46-db724551b384",
3+
"type": "misc",
4+
"description": "Add telemetry provider configuration to `DefaultAwsSigner`"
5+
}

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ jobs:
6262
- name: Test
6363
shell: bash
6464
run: |
65-
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
66-
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
65+
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
6766
./gradlew apiCheck
6867
./gradlew test jvmTest
6968
- name: Save Test Reports
7069
if: failure()
71-
uses: actions/upload-artifact@v3
70+
uses: actions/upload-artifact@v4
7271
with:
7372
name: test-reports-${{ matrix.os }}
7473
path: '**/build/reports'

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.4.2] - 01/28/2025
4+
5+
### Fixes
6+
* Ignore hop-by-hop headers when signing requests
7+
8+
## [1.4.1] - 01/16/2025
9+
310
## [1.4.0] - 01/15/2025
411

512
### Features

codegen/protocol-tests/model/error-correction-tests.smithy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ operation SayHelloXml { output: TestOutput, errors: [Error] }
3939

4040
structure TestOutputDocument with [TestStruct] {
4141
innerField: Nested,
42-
// FIXME: This trait fails smithy validator
43-
// @required
42+
43+
// Note: This shape _should_ be @required, but causes Smithy httpResponseTests validation to fail.
44+
// We expect `document` to be deserialized as `null` and enforce @required using a runtime check, but Smithy validator doesn't recognize / allow this.
4445
document: Document
4546
}
4647
structure TestOutput with [TestStruct] { innerField: Nested }
@@ -65,8 +66,8 @@ structure TestStruct {
6566
@required
6667
nestedListValue: NestedList
6768

68-
// FIXME: This trait fails smithy validator
69-
// @required
69+
// Note: This shape _should_ be @required, but causes Smithy httpResponseTests validation to fail.
70+
// We expect `nested` to be deserialized as `null` and enforce @required using a runtime check, but Smithy validator doesn't recognize / allow this.
7071
nested: Nested
7172

7273
@required
@@ -97,8 +98,7 @@ union MyUnion {
9798
}
9899

99100
structure Nested {
100-
// FIXME: This trait fails smithy validator
101-
// @required
101+
@required
102102
a: String
103103
}
104104

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/aws/protocols/core/AwsHttpBindingProtocolGenerator.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
4040
// val targetedTest = TestMemberDelta(setOf("RestJsonComplexErrorWithNoMessage"), TestContainmentMode.RUN_TESTS)
4141

4242
val ignoredTests = TestMemberDelta(
43-
setOf(
44-
"AwsJson10ClientErrorCorrectsWithDefaultValuesWhenServerFailsToSerializeRequiredValues",
45-
"RestJsonNullAndEmptyHeaders",
46-
"NullAndEmptyHeaders",
47-
"RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse",
48-
"RpcV2CborClientPopulatesDefaultValuesInInput",
49-
),
43+
setOf(),
5044
)
5145

5246
val requestTestBuilder = HttpProtocolUnitTestRequestGenerator.Builder()

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinSymbolProvider.kt

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
193193
} else {
194194
// only use @default if type is `T`
195195
shape.getTrait<DefaultTrait>()?.let {
196-
defaultValue(it.getDefaultValue(targetShape))
196+
setDefaultValue(it, targetShape)
197197
}
198198
}
199199
}
@@ -219,9 +219,10 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
219219
}
220220
}
221221

222-
private fun DefaultTrait.getDefaultValue(targetShape: Shape): String? {
223-
val node = toNode()
224-
return when {
222+
private fun Symbol.Builder.setDefaultValue(defaultTrait: DefaultTrait, targetShape: Shape) {
223+
val node = defaultTrait.toNode()
224+
225+
val defaultValue = when {
225226
node.toString() == "null" -> null
226227

227228
// Check if target is an enum before treating the default like a regular number/string
@@ -235,13 +236,20 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
235236
"${enumSymbol.fullName}.fromValue($arg)"
236237
}
237238

238-
targetShape.isBlobShape && targetShape.isStreaming ->
239-
node
240-
.toString()
241-
.takeUnless { it.isEmpty() }
242-
?.let { "ByteStream.fromString(${it.dq()})" }
239+
targetShape.isBlobShape -> {
240+
addReferences(RuntimeTypes.Core.Text.Encoding.decodeBase64)
243241

244-
targetShape.isBlobShape -> "${node.toString().dq()}.encodeToByteArray()"
242+
if (targetShape.isStreaming) {
243+
node.toString()
244+
.takeUnless { it.isEmpty() }
245+
?.let {
246+
addReferences(RuntimeTypes.Core.Content.ByteStream)
247+
"ByteStream.fromString(${it.dq()}.decodeBase64())"
248+
}
249+
} else {
250+
"${node.toString().dq()}.decodeBase64().encodeToByteArray()"
251+
}
252+
}
245253

246254
targetShape.isDocumentShape -> getDefaultValueForDocument(node)
247255
targetShape.isTimestampShape -> getDefaultValueForTimestamp(node.asNumberNode().get())
@@ -252,6 +260,8 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
252260
node.isStringNode -> node.toString().dq()
253261
else -> node.toString()
254262
}
263+
264+
defaultValue(defaultValue)
255265
}
256266

257267
private fun getDefaultValueForTimestamp(node: NumberNode): String {

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ class StructureGenerator(
248248
} else {
249249
memberSymbol
250250
}
251+
251252
write("public var #L: #E", memberName, builderMemberSymbol)
252253
}
253254
write("")

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/protocol/HttpStringValuesMapSerializer.kt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@ class HttpStringValuesMapSerializer(
157157
val paramName = binding.locationName
158158
// addAll collection parameter 2
159159
val param2 = if (mapFnContents.isEmpty()) "input.$memberName" else "input.$memberName.map { $mapFnContents }"
160-
val nullCheck = if (memberSymbol.isNullable) "?" else ""
161160
writer.write(
162-
"if (input.#L$nullCheck.isNotEmpty() == true) #L(#S, #L)",
161+
"if (input.#L != null) #L(#S, #L)",
163162
memberName,
164163
binding.location.addAllFnName,
165164
paramName,
@@ -174,8 +173,7 @@ class HttpStringValuesMapSerializer(
174173
val paramName = binding.locationName
175174
val memberSymbol = symbolProvider.toSymbol(binding.member)
176175

177-
// NOTE: query parameters are allowed to be empty, whereas headers should omit empty string
178-
// values from serde
176+
// NOTE: query parameters are allowed to be empty
179177
if ((location == HttpBinding.Location.QUERY || location == HttpBinding.Location.HEADER) && binding.member.hasTrait<IdempotencyTokenTrait>()) {
180178
// Call the idempotency token function if no supplied value.
181179
writer.addImport(RuntimeTypes.SmithyClient.IdempotencyTokenProviderExt)
@@ -185,18 +183,7 @@ class HttpStringValuesMapSerializer(
185183
paramName,
186184
)
187185
} else {
188-
val nullCheck =
189-
if (location == HttpBinding.Location.QUERY ||
190-
memberTarget.hasTrait<
191-
@Suppress("DEPRECATION")
192-
software.amazon.smithy.model.traits.EnumTrait,
193-
>()
194-
) {
195-
if (memberSymbol.isNullable) "input.$memberName != null" else ""
196-
} else {
197-
val nullCheck = if (memberSymbol.isNullable) "?" else ""
198-
"input.$memberName$nullCheck.isNotEmpty() == true"
199-
}
186+
val nullCheck = if (memberSymbol.isNullable) "input.$memberName != null" else ""
200187

201188
val cond = defaultCheck(binding.member) ?: nullCheck
202189

codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/core/SymbolProviderTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class SymbolProviderTest {
182182
"double,2.71828,2.71828",
183183
"byte,10,10.toByte()",
184184
"string,\"hello\",\"hello\"",
185-
"blob,\"abcdefg\",\"abcdefg\".encodeToByteArray()",
185+
"blob,\"abcdefg\",\"abcdefg\".decodeBase64().encodeToByteArray()",
186186
"boolean,true,true",
187187
"bigInteger,5,5",
188188
"bigDecimal,9.0123456789,9.0123456789",

0 commit comments

Comments
 (0)