Skip to content

Commit fc5ab84

Browse files
committed
Merge branch 'main' into feature/http-1.x
2 parents ef217a2 + eb261a4 commit fc5ab84

File tree

383 files changed

+140676
-97343
lines changed

Some content is hidden

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

383 files changed

+140676
-97343
lines changed

.changelog/1755104778.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.changelog/1759416345.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
applies_to: ["server"]
3+
authors: ["jasgin"]
4+
references: ["smithy-rs#4321"]
5+
breaking: false
6+
new_feature: true
7+
bug_fix: false
8+
---
9+
10+
Adds the custom traits `@validationException`, `@validationMessage`, `@validationFieldList`, `@validationFieldName`, and `@validationFieldMessage`
11+
for defining custom validation exceptions.

.github/workflows/ci.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ jobs:
6969
with:
7070
repository: awslabs/aws-sdk-rust
7171
path: aws-sdk-rust
72-
# The examples from aws-doc-sdk-examples are needed to see if smithy-rs changes break examples
73-
- uses: actions/checkout@v4
74-
with:
75-
repository: awsdocs/aws-doc-sdk-examples
76-
path: aws-doc-sdk-examples
7772
- name: Run ${{ matrix.actions.action }}
7873
uses: ./smithy-rs/.github/actions/docker-build
7974
with:
@@ -104,7 +99,7 @@ jobs:
10499
runner: smithy_ubuntu-latest_8-core
105100
fetch-depth: 0
106101
- action: check-sdk-codegen-unit-tests
107-
runner: ubuntu-latest
102+
runner: smithy_ubuntu-latest_8-core
108103
- action: check-fuzzgen
109104
runner: ubuntu-latest
110105
- action: check-server-codegen-integration-tests
@@ -115,6 +110,8 @@ jobs:
115110
runner: ubuntu-latest
116111
- action: check-server-codegen-unit-tests-python
117112
runner: ubuntu-latest
113+
- action: check-serde-codegen-unit-tests
114+
runner: ubuntu-latest
118115
- action: check-server-e2e-test
119116
runner: ubuntu-latest
120117
- action: check-server-python-e2e-test
@@ -127,6 +124,8 @@ jobs:
127124
runner: smithy_ubuntu-latest_8-core
128125
- action: check-deterministic-codegen
129126
runner: smithy_ubuntu-latest_8-core
127+
- action: check-codegen-version
128+
runner: ubuntu-latest
130129
steps:
131130
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
132131
- uses: actions/checkout@v4

.github/workflows/dry-run-release-scheduled.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ jobs:
3333
CANARY_GITHUB_ACTIONS_ROLE_ARN: ${{ secrets.CANARY_GITHUB_ACTIONS_ROLE_ARN }}
3434
CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME: ${{ secrets.CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME }}
3535
SMITHY_RS_ECR_PUSH_ROLE_ARN: ${{ secrets.SMITHY_RS_ECR_PUSH_ROLE_ARN }}
36+
MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN }}
37+
MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN }}
38+
MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN }}
39+
MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN }}

.github/workflows/dry-run-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ jobs:
4343
CANARY_GITHUB_ACTIONS_ROLE_ARN: ${{ secrets.CANARY_GITHUB_ACTIONS_ROLE_ARN }}
4444
CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME: ${{ secrets.CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME }}
4545
SMITHY_RS_ECR_PUSH_ROLE_ARN: ${{ secrets.SMITHY_RS_ECR_PUSH_ROLE_ARN }}
46+
MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN }}
47+
MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN }}
48+
MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN }}
49+
MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN }}

.github/workflows/prod-release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ jobs:
3737
CANARY_GITHUB_ACTIONS_ROLE_ARN: ${{ secrets.CANARY_GITHUB_ACTIONS_ROLE_ARN }}
3838
CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME: ${{ secrets.CANARY_STACK_CDK_OUTPUTS_BUCKET_NAME }}
3939
SMITHY_RS_ECR_PUSH_ROLE_ARN: ${{ secrets.SMITHY_RS_ECR_PUSH_ROLE_ARN }}
40+
MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN }}
41+
MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN }}
42+
MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN }}
43+
MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN }}

.github/workflows/release.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ on:
3939
required: true
4040
SMITHY_RS_ECR_PUSH_ROLE_ARN:
4141
required: true
42+
MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN:
43+
required: true
44+
MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN:
45+
required: true
46+
MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN:
47+
required: true
48+
MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN:
49+
required: true
4250

4351
jobs:
4452
check-actor-for-prod-run:
@@ -273,6 +281,81 @@ jobs:
273281
releaseCommitish: "${{ steps.push-changelog.outputs.commit_sha }}"
274282
});
275283
284+
publish-to-maven-central:
285+
name: Publish Codegen artifacts to Maven Central
286+
needs:
287+
- release
288+
if: always() && needs.release.result == 'success'
289+
runs-on: ubuntu-latest
290+
steps:
291+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
292+
- uses: actions/checkout@v4
293+
with:
294+
path: smithy-rs
295+
ref: ${{ inputs.commit_sha }}
296+
fetch-depth: 0
297+
- name: Set up JDK
298+
uses: actions/setup-java@v4
299+
with:
300+
distribution: temurin
301+
java-version: '17'
302+
- name: Check if publishing is needed
303+
id: check-publish
304+
shell: bash
305+
working-directory: smithy-rs
306+
run: |
307+
# Run the Gradle task to check if publishing is needed
308+
./gradlew checkMavenCentralPublishingNeeded
309+
310+
# Read the result from the build
311+
if grep -q "mavenCentralPublishingNeeded=true" build/maven-central/publishing.properties; then
312+
echo "publish=true" >> $GITHUB_OUTPUT
313+
else
314+
echo "publish=false" >> $GITHUB_OUTPUT
315+
fi
316+
- name: Acquire credentials
317+
if: steps.check-publish.outputs.publish == 'true'
318+
uses: aws-actions/configure-aws-credentials@v4
319+
with:
320+
role-to-assume: ${{ secrets.SMITHY_RS_ECR_PUSH_ROLE_ARN }}
321+
role-session-name: GitHubActions
322+
aws-region: us-west-2
323+
- name: Publish to Maven Central
324+
if: steps.check-publish.outputs.publish == 'true'
325+
shell: bash
326+
working-directory: smithy-rs
327+
env:
328+
GPG_PUBLIC_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PUBLIC_KEY_SECRET_ARN }}
329+
GPG_PRIVATE_KEY_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PRIVATE_KEY_SECRET_ARN }}
330+
GPG_PASSPHRASE_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_GPG_PASSPHRASE_SECRET_ARN }}
331+
SONATYPE_CREDENTIALS_SECRET_ARN: ${{ secrets.MAVEN_CENTRAL_SONATYPE_CREDENTIALS_SECRET_ARN }}
332+
JRELEASER_DRY_RUN: ${{ inputs.dry_run }}
333+
run: |
334+
pwd
335+
# Get secrets from AWS Secrets Manager
336+
GPG_PUBLIC_KEY=$(aws secretsmanager get-secret-value --secret-id $GPG_PUBLIC_KEY_SECRET_ARN --query SecretString --output text)
337+
GPG_PRIVATE_KEY=$(aws secretsmanager get-secret-value --secret-id $GPG_PRIVATE_KEY_SECRET_ARN --query SecretString --output text)
338+
GPG_PASSPHRASE=$(aws secretsmanager get-secret-value --secret-id $GPG_PASSPHRASE_SECRET_ARN --query SecretString --output text)
339+
340+
# Get Sonatype credentials from JSON secret
341+
SONATYPE_CREDS=$(aws secretsmanager get-secret-value --secret-id $SONATYPE_CREDENTIALS_SECRET_ARN --query SecretString --output text)
342+
MAVEN_CENTRAL_USERNAME=$(echo $SONATYPE_CREDS | jq -r '.["sonatype-portal-token-username"]')
343+
MAVEN_CENTRAL_TOKEN=$(echo $SONATYPE_CREDS | jq -r '.["sonatype-portal-token"]')
344+
345+
# Set up JReleaser environment variables
346+
export JRELEASER_GPG_PUBLIC_KEY="$GPG_PUBLIC_KEY"
347+
export JRELEASER_GPG_SECRET_KEY="$GPG_PRIVATE_KEY"
348+
export JRELEASER_GPG_PASSPHRASE="$GPG_PASSPHRASE"
349+
export JRELEASER_MAVENCENTRAL_USERNAME="$MAVEN_CENTRAL_USERNAME"
350+
export JRELEASER_MAVENCENTRAL_TOKEN="$MAVEN_CENTRAL_TOKEN"
351+
export JRELEASER_GENERIC_TOKEN=not-used-but-must-be-set
352+
353+
# Run Gradle publish task to stage outputs to build/m2 directory
354+
./gradlew publish
355+
ls -lsa build/m2/software/amazon/smithy/rust
356+
./gradlew jreleaserConfig
357+
./gradlew jreleaserFullRelease
358+
276359
# If this step fails for any reason, there's no need to retry the release workflow, as this step is auxiliary
277360
# and the release itself was successful. Instead, manually trigger `backport-pull-request.yml`.
278361
open-backport-pull-request:

AGENTS.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Smithy-rs AI Agent Guide
2+
3+
## Package Layout
4+
5+
- **`codegen-core/`** - Shared codegen
6+
- **`codegen-server/`** - Server codegen
7+
- **`codegen-client/`** - Client codegen
8+
- **`rust-runtime/`** - Runtime libraries
9+
- **`codegen-server-test/`** - Server integration tests
10+
11+
Protocol files: `codegen-{core,server}/.../protocols/`
12+
13+
## preludeScope: Rust Prelude Types
14+
15+
**Always use `preludeScope` for Rust prelude types:**
16+
17+
```kotlin
18+
rustTemplate(
19+
"let result: #{Result}<#{String}, #{Error}> = #{Ok}(value);",
20+
*preludeScope, // Provides Result, String, Ok
21+
"Error" to myErrorType
22+
)
23+
```
24+
25+
❌ Wrong: `"let result: Result<String, Error> = Ok(value);"`
26+
✅ Correct: Use `*preludeScope` in templates
27+
28+
## RuntimeType and Dependencies
29+
30+
`RuntimeType` objects contain:
31+
- **`path`**: Rust path (e.g., `"::mime::Mime"`)
32+
- **`dependency`**: `CargoDependency` or `InlineDependency`
33+
34+
Using a `RuntimeType` automatically adds its dependency to `Cargo.toml`.
35+
36+
### Creating RuntimeTypes
37+
38+
```kotlin
39+
// Pre-defined dependencies
40+
val Mime = CargoDependency.Mime.toType()
41+
val Bytes = CargoDependency.Bytes.toType().resolve("Bytes")
42+
43+
// Runtime crates
44+
val smithyTypes = RuntimeType.smithyTypes(runtimeConfig)
45+
```
46+
47+
### Always Use Symbols
48+
49+
❌ Wrong: `rust("const MIME: ::mime::Mime = ::mime::APPLICATION_JSON;")`
50+
✅ Correct: `rustTemplate("const MIME: #{Mime}::Mime = #{Mime}::APPLICATION_JSON;", "Mime" to RuntimeType.Mime)`
51+
52+
## RuntimeType.forInlineFun: Lazy Generation
53+
54+
Code is only generated if used. `forInlineFun` enables lazy generation:
55+
56+
```kotlin
57+
val mimeType = RuntimeType.forInlineFun("APPLICATION_JSON", module) {
58+
rustTemplate(
59+
"pub const APPLICATION_JSON: #{Mime}::Mime = #{Mime}::APPLICATION_JSON;",
60+
"Mime" to RuntimeType.Mime
61+
)
62+
}
63+
```
64+
65+
⚠️ **Footgun**: Name collisions mean only one implementation gets generated.
66+
67+
## Testing
68+
69+
### Integration Tests
70+
Test actual generated code, not just codegen logic:
71+
72+
```kotlin
73+
serverIntegrationTest(model) { codegenContext, rustCrate ->
74+
rustCrate.testModule {
75+
tokioTest("test_accept_header") {
76+
rustTemplate("""
77+
let request = ::http::Request::builder()
78+
.header("Accept", "application/cbor")
79+
.body(Body::empty()).unwrap();
80+
let result = MyInput::from_request(request).await;
81+
result.expect("should accept valid header");
82+
""")
83+
}
84+
}
85+
}
86+
```
87+
88+
### Running Tests
89+
90+
**Codegen tests:**
91+
```bash
92+
./gradlew test --tests "*MyTest*"
93+
./gradlew codegen-server-test:assemble --quiet
94+
```
95+
96+
**Debug failing tests:**
97+
```bash
98+
# Remove --quiet to see failure details
99+
./gradlew :codegen-core:test --tests "*InlineDependencyTest*"
100+
# Extract just the error from HTML report (avoid HTML markup pollution)
101+
grep -A 5 "AssertionError\|Exception" codegen-core/build/reports/tests/test/classes/software.amazon.smithy.rust.codegen.core.rustlang.InlineDependencyTest.html
102+
```
103+
104+
**Runtime tests:**
105+
```bash
106+
cd rust-runtime && cargo test --quiet -p aws-smithy-types
107+
```
108+
109+
**Protocol tests:**
110+
```bash
111+
./gradlew codegen-client-test:assemble --quiet
112+
cd codegen-client-test/build/smithyprojections/codegen-client-test/rest_xml_extras/rust-client-codegen
113+
cargo test --quiet
114+
```
115+
116+
## Viewing Generated Code
117+
118+
Generated code appears in:
119+
```
120+
codegen-server-test/build/smithyprojections/codegen-server-test/SERVICE_NAME/rust-server-codegen/
121+
```
122+
123+
Enable debug comments:
124+
```kotlin
125+
serverIntegrationTest(model, IntegrationTestParams(
126+
additionalSettings = ServerAdditionalSettings.builder()
127+
.generateCodegenComments() // Adds Kotlin source line comments
128+
.toObjectNode()
129+
)) { /* test code */ }
130+
```

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
<!-- Do not manually edit this file. Use the `changelogger` tool. -->
2+
October 2nd, 2025
3+
=================
4+
**New this release:**
5+
- :bug: (server) Fix bug where servers rejected `application/vnd.amazon.evenstream` ACCEPT header for RPCv2Cbor
6+
7+
This change allows this header while also allowing `application/cbor` for backwards compatibility.
8+
9+
10+
October 1st, 2025
11+
=================
12+
**New this release:**
13+
- :tada: (client, [smithy-rs#4299](https://github.com/smithy-lang/smithy-rs/issues/4299), @greenwoodcm) Added a new `then_compute_output` to `aws-smithy-mocks` rule builder that allows using the input type when computing a mocked response, e.g.
14+
```rs
15+
// Return a computed output based on the input
16+
let compute_rule = mock!(Client::get_object)
17+
.then_compute_output(|req| {
18+
let key = req.key().unwrap_or("unknown");
19+
GetObjectOutput::builder()
20+
.body(ByteStream::from_static(format!("content for {}", key).as_bytes()))
21+
.build()
22+
});
23+
```
24+
- :bug: (client, [smithy-rs#4226](https://github.com/smithy-lang/smithy-rs/issues/4226), @haydenbaker) Fixed problematic assertion on HttpApiKeyAuthTrait `scheme`, which was causing client-codegen to fail when the correct settings for api-key based auth were set.
25+
26+
**Contributors**
27+
Thank you for your contributions!
28+
- @greenwoodcm ([smithy-rs#4299](https://github.com/smithy-lang/smithy-rs/issues/4299))
29+
- @haydenbaker ([smithy-rs#4226](https://github.com/smithy-lang/smithy-rs/issues/4226))
30+
31+
32+
September 10th, 2025
33+
====================
34+
**New this release:**
35+
- :bug: (client, [smithy-rs#4274](https://github.com/smithy-lang/smithy-rs/issues/4274)) The `HickoryDnsResolver` and `TokioDnsResolver` were not `Clone` making it impossible to use them in the http_client builder's `build_with_resolver` method.
36+
37+
38+
August 28th, 2025
39+
=================
40+
**New this release:**
41+
- :tada: (client, [smithy-rs#4274](https://github.com/smithy-lang/smithy-rs/issues/4274)) Add a new crate, `aws-smithy-dns` that contains a `HickoryDnsResolver`. This wraps a `hickory_resolver::Resolver` and provides some minimal configuration options (timeouts, retries, etc.) Instructions for overriding the DNS resolver on your HTTP client can be found in our documentation at https://docs.aws.amazon.com/sdk-for-rust/latest/dg/http.html#overrideDns
42+
- :bug: (client, [smithy-rs#4282](https://github.com/smithy-lang/smithy-rs/issues/4282)) Set the `pool_timer` for the default Hyper client. This is required to allow the `pool_idle_timeout` to work. Now idle connections will be released by the pool after 90 seconds.
43+
- (client, [smithy-rs#4263](https://github.com/smithy-lang/smithy-rs/issues/4263)) Make [`TokenBucket`](https://docs.rs/aws-smithy-runtime/latest/aws_smithy_runtime/client/retries/struct.TokenBucket.html) and [`ClientRateLimiter`](https://docs.rs/aws-smithy-runtime/latest/aws_smithy_runtime/client/retries/struct.ClientRateLimiter.html) configurable through [`RetryPartition`](https://docs.rs/aws-smithy-runtime/latest/aws_smithy_runtime/client/retries/struct.RetryPartition.html).
44+
45+
246
August 18th, 2025
347
=================
448
**New this release:**

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Project Layout
3434
installed for FIP support to compile properly)
3535
* `./gradlew :aws:sdk:{cargoCheck, cargoTest, cargoDocs, cargoClippy}`: Generate & run specified cargo command.
3636
* `codegen-core`: Common code generation logic useful for clients and servers
37-
* `codegen-client`: Whitelabel Smithy client code generation
37+
* `codegen-client`: Smithy client code generation
3838
* `codegen-client-test`: Smithy protocol test generation & integration tests for Smithy client whitelabel code
3939
* [`design`](design): Design documentation. See the [design/README.md](design/README.md) for details about building / viewing.
40-
* `codegen-server`: Whitelabel Smithy server code generation
40+
* `codegen-server`: Smithy server code generation
4141
* `codegen-server-test`: Smithy protocol test generation & integration tests for Smithy server whitelabel code
4242
* `examples`: A collection of server implementation examples
4343

@@ -53,7 +53,7 @@ In general, the components of smithy-rs affect each other in the following order
5353
1. `rust-runtime`
5454
2. `codegen` and `codegen-server`
5555
3. `aws/rust-runtime`
56-
4. `aws/sdk-codegen`
56+
4. `aws/codegen-aws-sdk`
5757

5858
Some components, such as `codegen-client-test` and `codegen-server-test`, are purely for testing other components.
5959

@@ -120,7 +120,7 @@ to generate more or less AWS service clients.
120120

121121
```bash
122122
# Run Kotlin codegen unit tests
123-
./gradlew aws:sdk-codegen:check
123+
./gradlew aws:codegen-aws-sdk:check
124124
# Generate an SDK, but do not attempt to compile / run tests. Useful for inspecting generated code
125125
./gradlew :aws:sdk:assemble
126126
# Run all the tests

0 commit comments

Comments
 (0)