Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a4734c7
fix: create JMESPATH flattenIfPossible functions for Lists (#1169)
0marperez Dec 16, 2024
7911a94
chore: release 1.3.30
aws-sdk-kotlin-ci Dec 16, 2024
7085c8a
chore: bump snapshot version to 1.3.31-SNAPSHOT
aws-sdk-kotlin-ci Dec 16, 2024
4575023
misc: enhance support for replayable instances of `InputStream` (#1197)
lauzadis Dec 18, 2024
b0a4bac
chore: release 1.3.31
aws-sdk-kotlin-ci Dec 18, 2024
80f4538
chore: bump snapshot version to 1.3.32-SNAPSHOT
aws-sdk-kotlin-ci Dec 18, 2024
e9d16a9
fix: CBOR protocol test assertions / blob serialization (#1198)
lauzadis Dec 18, 2024
48849a1
fix: correctly serialize subset of shape's members when configured (#…
lauzadis Jan 6, 2025
ded3a4b
chore: release 1.3.32
aws-sdk-kotlin-ci Jan 6, 2025
d97e8ba
chore: bump snapshot version to 1.3.33-SNAPSHOT
aws-sdk-kotlin-ci Jan 6, 2025
49f464b
Initial GZIP implementation
lauzadis Jan 7, 2025
9ff5e32
Remove printlns and clean up
lauzadis Jan 7, 2025
28d46fc
ktlint
lauzadis Jan 7, 2025
78f17f3
chore: add *-main to branch workflows (#1209)
ianbotsf Jan 8, 2025
d06ee0a
chore: add .kotlin/ to .gitignore (#1208)
ianbotsf Jan 8, 2025
d2e7c91
chore: smithy version bump (#1213)
0marperez Jan 10, 2025
5a2df8f
chore: release 1.3.33
aws-sdk-kotlin-ci Jan 10, 2025
003633b
chore: bump snapshot version to 1.3.34-SNAPSHOT
aws-sdk-kotlin-ci Jan 10, 2025
5f5ec8f
feat: add `AuthTokenGenerator` (#1212)
lauzadis Jan 10, 2025
3fe1b5e
chore: release 1.3.34
aws-sdk-kotlin-ci Jan 10, 2025
0bba308
chore: bump snapshot version to 1.3.35-SNAPSHOT
aws-sdk-kotlin-ci Jan 10, 2025
fbcb79c
Merge branch 'kn-main' of github.com:smithy-lang/smithy-kotlin into k…
lauzadis Jan 10, 2025
52e4439
misc: merge v1.4 into main (#1218)
0marperez Jan 15, 2025
e0c25d6
feat: support default checksums (#1191)
0marperez Jan 15, 2025
14e0958
chore: release 1.4.0
aws-sdk-kotlin-ci Jan 15, 2025
ed95d7b
chore: bump snapshot version to 1.4.1-SNAPSHOT
aws-sdk-kotlin-ci Jan 15, 2025
a4ace35
fix: add 0.9.x aws-crt-kotlin transform (#1220)
lauzadis Jan 16, 2025
15e5f0c
fix: Ensure `Host` header is included when signing auth tokens (#1222)
lauzadis Jan 16, 2025
447ac10
chore: release 1.4.1
aws-sdk-kotlin-ci Jan 16, 2025
0f8db44
chore: bump snapshot version to 1.4.2-SNAPSHOT
aws-sdk-kotlin-ci Jan 16, 2025
260a212
Merge branch 'kn-main' of github.com:smithy-lang/smithy-kotlin into k…
lauzadis Jan 22, 2025
8b33693
fix: address various failing protocol tests (#1223)
lauzadis Jan 23, 2025
03badf9
misc: re-enable `kotlinWarningsAsErrors=true` (#1224)
lauzadis Jan 23, 2025
3143a01
Merge branch 'kn-main' of github.com:smithy-lang/smithy-kotlin into k…
lauzadis Jan 27, 2025
acae410
Fix `decompressGzipBytes` duplication
lauzadis Jan 28, 2025
95350cb
Replace `@IgnoreNative`, still missing some implementations
lauzadis Jan 28, 2025
913f534
Fix duplicated `decompressGzipBytes`
lauzadis Jan 28, 2025
9f44cdb
fix: ignore hop-by-hop headers when signing requests (#1227)
ianbotsf Jan 28, 2025
97ac447
chore: release 1.4.2
aws-sdk-kotlin-ci Jan 28, 2025
b7e50e3
chore: bump snapshot version to 1.4.3-SNAPSHOT
aws-sdk-kotlin-ci Jan 28, 2025
edd846a
Implement `GzipCompressor`, enable all gzip tests
lauzadis Jan 29, 2025
958e9f0
ktlint
lauzadis Jan 29, 2025
45e455d
Revert comment change
lauzadis Jan 29, 2025
d543e03
Revert comment change
lauzadis Jan 29, 2025
29bb5ff
Remove consts
lauzadis Jan 29, 2025
e08055e
Remove outdated comment
lauzadis Jan 29, 2025
cc45358
ktlint
lauzadis Jan 29, 2025
e6357f9
misc: add telemetry configuration to DefaultAwsSigner (#1226)
xinsong-cui Jan 30, 2025
477201d
Use `check`, simplify atomic with boolean
lauzadis Jan 30, 2025
c8408a7
Implement `Closeable`
lauzadis Jan 30, 2025
45316dd
ByteStream.fromBytes
lauzadis Jan 30, 2025
06621fa
`const`
lauzadis Jan 30, 2025
4b4c628
Update `check`
lauzadis Jan 30, 2025
b882663
Refactor to buffer output using `SdkByteChannel`
lauzadis Jan 31, 2025
2794930
ktlint
lauzadis Jan 31, 2025
755cc4b
Refactor to use `asByteStream`
lauzadis Jan 31, 2025
f3b8e7f
Update Gzip ByteStream.Buffer compression
lauzadis Jan 31, 2025
9eea733
apiDump
lauzadis Jan 31, 2025
a4f7ba6
Use upload-artifact@v4
lauzadis Jan 31, 2025
bc3221d
Refactor to use SdkBuffer
lauzadis Feb 3, 2025
002ae42
Remove stray `runBlocking` calls
lauzadis Feb 3, 2025
be2a662
Merge branch 'main' of github.com:smithy-lang/smithy-kotlin into kn-gzip
lauzadis Feb 3, 2025
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
5 changes: 5 additions & 0 deletions .changes/d3ce7511-6fb2-4435-8f46-db724551b384.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"id": "d3ce7511-6fb2-4435-8f46-db724551b384",
"type": "misc",
"description": "Add telemetry provider configuration to `DefaultAwsSigner`"
}
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Save Test Reports
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.os }}
path: '**/build/reports'
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:

- name: Save Test Reports
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.os }}
path: '**/build/reports'
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [1.4.2] - 01/28/2025

### Fixes
* Ignore hop-by-hop headers when signing requests

## [1.4.1] - 01/16/2025

## [1.4.0] - 01/15/2025
Expand Down
12 changes: 6 additions & 6 deletions codegen/protocol-tests/model/error-correction-tests.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ operation SayHelloXml { output: TestOutput, errors: [Error] }

structure TestOutputDocument with [TestStruct] {
innerField: Nested,
// FIXME: This trait fails smithy validator
// @required

// Note: This shape _should_ be @required, but causes Smithy httpResponseTests validation to fail.
// We expect `document` to be deserialized as `null` and enforce @required using a runtime check, but Smithy validator doesn't recognize / allow this.
document: Document
}
structure TestOutput with [TestStruct] { innerField: Nested }
Expand All @@ -65,8 +66,8 @@ structure TestStruct {
@required
nestedListValue: NestedList

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

@required
Expand Down Expand Up @@ -97,8 +98,7 @@ union MyUnion {
}

structure Nested {
// FIXME: This trait fails smithy validator
// @required
@required
a: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
// val targetedTest = TestMemberDelta(setOf("RestJsonComplexErrorWithNoMessage"), TestContainmentMode.RUN_TESTS)

val ignoredTests = TestMemberDelta(
setOf(
"AwsJson10ClientErrorCorrectsWithDefaultValuesWhenServerFailsToSerializeRequiredValues",
"RestJsonNullAndEmptyHeaders",
"NullAndEmptyHeaders",
"RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse",
"RpcV2CborClientPopulatesDefaultValuesInInput",
),
setOf(),
)

val requestTestBuilder = HttpProtocolUnitTestRequestGenerator.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
} else {
// only use @default if type is `T`
shape.getTrait<DefaultTrait>()?.let {
defaultValue(it.getDefaultValue(targetShape))
setDefaultValue(it, targetShape)
}
}
}
Expand All @@ -219,9 +219,10 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
}
}

private fun DefaultTrait.getDefaultValue(targetShape: Shape): String? {
val node = toNode()
return when {
private fun Symbol.Builder.setDefaultValue(defaultTrait: DefaultTrait, targetShape: Shape) {
val node = defaultTrait.toNode()

val defaultValue = when {
node.toString() == "null" -> null

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

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

targetShape.isBlobShape -> "${node.toString().dq()}.encodeToByteArray()"
if (targetShape.isStreaming) {
node.toString()
.takeUnless { it.isEmpty() }
?.let {
addReferences(RuntimeTypes.Core.Content.ByteStream)
"ByteStream.fromString(${it.dq()}.decodeBase64())"
}
} else {
"${node.toString().dq()}.decodeBase64().encodeToByteArray()"
}
}

targetShape.isDocumentShape -> getDefaultValueForDocument(node)
targetShape.isTimestampShape -> getDefaultValueForTimestamp(node.asNumberNode().get())
Expand All @@ -252,6 +260,8 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
node.isStringNode -> node.toString().dq()
else -> node.toString()
}

defaultValue(defaultValue)
}

private fun getDefaultValueForTimestamp(node: NumberNode): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class StructureGenerator(
} else {
memberSymbol
}

write("public var #L: #E", memberName, builderMemberSymbol)
}
write("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ class HttpStringValuesMapSerializer(
val paramName = binding.locationName
// addAll collection parameter 2
val param2 = if (mapFnContents.isEmpty()) "input.$memberName" else "input.$memberName.map { $mapFnContents }"
val nullCheck = if (memberSymbol.isNullable) "?" else ""
writer.write(
"if (input.#L$nullCheck.isNotEmpty() == true) #L(#S, #L)",
"if (input.#L != null) #L(#S, #L)",
memberName,
binding.location.addAllFnName,
paramName,
Expand All @@ -174,8 +173,7 @@ class HttpStringValuesMapSerializer(
val paramName = binding.locationName
val memberSymbol = symbolProvider.toSymbol(binding.member)

// NOTE: query parameters are allowed to be empty, whereas headers should omit empty string
// values from serde
// NOTE: query parameters are allowed to be empty
if ((location == HttpBinding.Location.QUERY || location == HttpBinding.Location.HEADER) && binding.member.hasTrait<IdempotencyTokenTrait>()) {
// Call the idempotency token function if no supplied value.
writer.addImport(RuntimeTypes.SmithyClient.IdempotencyTokenProviderExt)
Expand All @@ -185,18 +183,7 @@ class HttpStringValuesMapSerializer(
paramName,
)
} else {
val nullCheck =
if (location == HttpBinding.Location.QUERY ||
memberTarget.hasTrait<
@Suppress("DEPRECATION")
software.amazon.smithy.model.traits.EnumTrait,
>()
) {
if (memberSymbol.isNullable) "input.$memberName != null" else ""
} else {
val nullCheck = if (memberSymbol.isNullable) "?" else ""
"input.$memberName$nullCheck.isNotEmpty() == true"
}
val nullCheck = if (memberSymbol.isNullable) "input.$memberName != null" else ""

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SymbolProviderTest {
"double,2.71828,2.71828",
"byte,10,10.toByte()",
"string,\"hello\",\"hello\"",
"blob,\"abcdefg\",\"abcdefg\".encodeToByteArray()",
"blob,\"abcdefg\",\"abcdefg\".decodeBase64().encodeToByteArray()",
"boolean,true,true",
"bigInteger,5,5",
"bigDecimal,9.0123456789,9.0123456789",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ internal class SmokeTestOperationSerializer: HttpSerializer.NonStreaming<SmokeTe
}

builder.headers {
if (input.header1?.isNotEmpty() == true) append("X-Header1", input.header1)
if (input.header2?.isNotEmpty() == true) append("X-Header2", input.header2)
if (input.header1 != null) append("X-Header1", input.header1)
if (input.header2 != null) append("X-Header2", input.header2)
}

val payload = serializeSmokeTestOperationBody(context, input)
Expand Down Expand Up @@ -264,7 +264,7 @@ internal class TimestampInputOperationSerializer: HttpSerializer.NonStreaming<Ti
}
parameters.decodedParameters(PercentEncoding.SmithyLabel) {
if (input.queryTimestamp != null) add("qtime", input.queryTimestamp.format(TimestampFormat.ISO_8601))
if (input.queryTimestampList?.isNotEmpty() == true) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
if (input.queryTimestampList != null) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
}
}

Expand Down Expand Up @@ -304,7 +304,7 @@ internal class BlobInputOperationSerializer: HttpSerializer.NonStreaming<BlobInp
}

builder.headers {
if (input.headerMediaType?.isNotEmpty() == true) append("X-Blob", input.headerMediaType.encodeBase64())
if (input.headerMediaType != null) append("X-Blob", input.headerMediaType.encodeBase64())
}

val payload = serializeBlobInputOperationBody(context, input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class HttpStringValuesMapSerializerTest {
contents.assertBalancedBracesAndParens()

val expectedContents = """
if (input.header1?.isNotEmpty() == true) append("X-Header1", input.header1)
if (input.header2?.isNotEmpty() == true) append("X-Header2", input.header2)
if (input.header1 != null) append("X-Header1", input.header1)
if (input.header2 != null) append("X-Header2", input.header2)
""".trimIndent()
contents.shouldContainOnlyOnceWithDiff(expectedContents)
}
Expand All @@ -157,7 +157,7 @@ class HttpStringValuesMapSerializerTest {
contents.assertBalancedBracesAndParens()

val expectedContents = """
if (input.headerMediaType?.isNotEmpty() == true) append("X-Blob", input.headerMediaType.encodeBase64())
if (input.headerMediaType != null) append("X-Blob", input.headerMediaType.encodeBase64())
""".trimIndent()
contents.shouldContainOnlyOnceWithDiff(expectedContents)
}
Expand All @@ -168,10 +168,10 @@ class HttpStringValuesMapSerializerTest {
contents.assertBalancedBracesAndParens()

val expectedContents = """
if (input.enumList?.isNotEmpty() == true) appendAll("x-enumList", input.enumList.map { quoteHeaderValue(it.value) })
if (input.intList?.isNotEmpty() == true) appendAll("x-intList", input.intList.map { it.toString() })
if (input.strList?.isNotEmpty() == true) appendAll("x-strList", input.strList.map { quoteHeaderValue(it) })
if (input.tsList?.isNotEmpty() == true) appendAll("x-tsList", input.tsList.map { it.format(TimestampFormat.RFC_5322) })
if (input.enumList != null) appendAll("x-enumList", input.enumList.map { quoteHeaderValue(it.value) })
if (input.intList != null) appendAll("x-intList", input.intList.map { it.toString() })
if (input.strList != null) appendAll("x-strList", input.strList.map { quoteHeaderValue(it) })
if (input.tsList != null) appendAll("x-tsList", input.tsList.map { it.format(TimestampFormat.RFC_5322) })
""".trimIndent()
contents.shouldContainOnlyOnceWithDiff(expectedContents)
}
Expand All @@ -190,7 +190,7 @@ class HttpStringValuesMapSerializerTest {
val queryContents = getTestContents(defaultModel, "com.test#TimestampInput", HttpBinding.Location.QUERY)
val expectedQueryContents = """
if (input.queryTimestamp != null) add("qtime", input.queryTimestamp.format(TimestampFormat.ISO_8601))
if (input.queryTimestampList?.isNotEmpty() == true) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
if (input.queryTimestampList != null) addAll("qtimeList", input.queryTimestampList.map { it.format(TimestampFormat.ISO_8601) })
""".trimIndent()
queryContents.shouldContainOnlyOnceWithDiff(expectedQueryContents)
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kotlinx.atomicfu.enableNativeIrTransformation=false
org.gradle.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=1G

# SDK
sdkVersion=1.4.2-SNAPSHOT
sdkVersion=1.4.3-SNAPSHOT

# codegen
codegenVersion=0.34.2-SNAPSHOT
codegenVersion=0.34.3-SNAPSHOT
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kotlin-version = "2.1.0"
dokka-version = "1.9.10"

aws-kotlin-repo-tools-version = "0.4.21-kn"
aws-kotlin-repo-tools-version = "0.4.22-kn"

# libs
coroutines-version = "1.9.0"
Expand All @@ -13,14 +13,14 @@ okio-version = "3.9.1"
otel-version = "1.45.0"
slf4j-version = "2.0.16"
slf4j-v1x-version = "1.7.36"
crt-kotlin-version = "0.9.0"
crt-kotlin-version = "0.9.1"
micrometer-version = "1.14.2"
kotlin-multiplatform-bignum-version = "0.3.10"
kotlinx-datetime-version = "0.6.1"
binary-compatibility-validator-version = "0.16.3"

# codegen
smithy-version = "1.53.0"
smithy-version = "1.54.0"
smithy-gradle-version = "0.9.0"

# testing
Expand Down
8 changes: 8 additions & 0 deletions runtime/auth/aws-signing-default/api/aws-signing-default.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
public final class aws/smithy/kotlin/runtime/auth/awssigning/DefaultAwsSignerBuilder {
public fun <init> ()V
public final fun build ()Laws/smithy/kotlin/runtime/auth/awssigning/AwsSigner;
public final fun getTelemetryProvider ()Laws/smithy/kotlin/runtime/telemetry/TelemetryProvider;
public final fun setTelemetryProvider (Laws/smithy/kotlin/runtime/telemetry/TelemetryProvider;)V
}

public final class aws/smithy/kotlin/runtime/auth/awssigning/DefaultAwsSignerKt {
public static final fun DefaultAwsSigner (Lkotlin/jvm/functions/Function1;)Laws/smithy/kotlin/runtime/auth/awssigning/AwsSigner;
public static final fun getDefaultAwsSigner ()Laws/smithy/kotlin/runtime/auth/awssigning/AwsSigner;
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,27 @@ internal interface Canonicalizer {
): CanonicalRequest
}

// Taken from https://github.com/awslabs/aws-c-auth/blob/dd505b55fd46222834f35c6e54165d8cbebbfaaa/source/aws_signing.c#L118-L156
private val skipHeaders = setOf(
"connection",
"expect", // https://github.com/awslabs/aws-sdk-kotlin/issues/862

// Taken from https://github.com/awslabs/aws-c-auth/blob/274a1d21330731cc51bb742794adc70ada5f4380/source/aws_signing.c#L121-L164
"sec-websocket-key",
"sec-websocket-protocol",
"sec-websocket-version",
"upgrade",
"user-agent",
"x-amzn-trace-id",

// Taken from https://datatracker.ietf.org/doc/html/rfc2616#section-13.5.1. These are "hop-by-hop" headers which may
// be modified/removed by intervening proxies or caches. These are unsafe to sign because if they change they render
// the signature invalid.
"connection",
"keep-alive",
"proxy-authenticate",
"proxy-authorization",
"te",
"trailers",
"transfer-encoding",
"upgrade",
)

internal class DefaultCanonicalizer(private val sha256Supplier: HashSupplier = ::Sha256) : Canonicalizer {
Expand Down
Loading
Loading