Skip to content

Commit 99d1214

Browse files
authored
kn: gzip compression (#1228)
1 parent 9c6b231 commit 99d1214

File tree

43 files changed

+548
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+548
-164
lines changed
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
7474
- name: Save Test Reports
7575
if: failure()
76-
uses: actions/upload-artifact@v3
76+
uses: actions/upload-artifact@v4
7777
with:
7878
name: test-reports-${{ matrix.os }}
7979
path: '**/build/reports'
@@ -107,7 +107,7 @@ jobs:
107107
108108
- name: Save Test Reports
109109
if: failure()
110-
uses: actions/upload-artifact@v3
110+
uses: actions/upload-artifact@v4
111111
with:
112112
name: test-reports-${{ matrix.os }}
113113
path: '**/build/reports'

CHANGELOG.md

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

3+
## [1.4.2] - 01/28/2025
4+
5+
### Fixes
6+
* Ignore hop-by-hop headers when signing requests
7+
38
## [1.4.1] - 01/16/2025
49

510
## [1.4.0] - 01/15/2025

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",

codegen/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/rendering/protocol/HttpBindingProtocolGeneratorTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ internal class SmokeTestOperationSerializer: HttpSerializer.NonStreaming<SmokeTe
5757
}
5858
5959
builder.headers {
60-
if (input.header1?.isNotEmpty() == true) append("X-Header1", input.header1)
61-
if (input.header2?.isNotEmpty() == true) append("X-Header2", input.header2)
60+
if (input.header1 != null) append("X-Header1", input.header1)
61+
if (input.header2 != null) append("X-Header2", input.header2)
6262
}
6363
6464
val payload = serializeSmokeTestOperationBody(context, input)
@@ -264,7 +264,7 @@ internal class TimestampInputOperationSerializer: HttpSerializer.NonStreaming<Ti
264264
}
265265
parameters.decodedParameters(PercentEncoding.SmithyLabel) {
266266
if (input.queryTimestamp != null) add("qtime", input.queryTimestamp.format(TimestampFormat.ISO_8601))
267-
if (input.queryTimestampList?.isNotEmpty() == true) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
267+
if (input.queryTimestampList != null) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
268268
}
269269
}
270270
@@ -304,7 +304,7 @@ internal class BlobInputOperationSerializer: HttpSerializer.NonStreaming<BlobInp
304304
}
305305
306306
builder.headers {
307-
if (input.headerMediaType?.isNotEmpty() == true) append("X-Blob", input.headerMediaType.encodeBase64())
307+
if (input.headerMediaType != null) append("X-Blob", input.headerMediaType.encodeBase64())
308308
}
309309
310310
val payload = serializeBlobInputOperationBody(context, input)

0 commit comments

Comments
 (0)