diff --git a/.changelog/1762045039.md b/.changelog/1762045039.md new file mode 100644 index 00000000000..c955ec6e6e3 --- /dev/null +++ b/.changelog/1762045039.md @@ -0,0 +1,12 @@ +--- +applies_to: +- server +authors: +- drganjoo +references: +- smithy-rs#9999 +breaking: false +new_feature: false +bug_fix: true +--- +Fix missing BuildError support in aws_json ResponseRejection. This fixes compilation errors when using AwsJson protocols with streaming operations. diff --git a/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/AwsJsonCompilationTest.kt b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/AwsJsonCompilationTest.kt new file mode 100644 index 00000000000..d9cfd62095b --- /dev/null +++ b/codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/AwsJsonCompilationTest.kt @@ -0,0 +1,42 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +package software.amazon.smithy.rust.codegen.server.smithy + +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import software.amazon.smithy.rust.codegen.core.testutil.IntegrationTestParams +import software.amazon.smithy.rust.codegen.core.testutil.ServerAdditionalSettings +import software.amazon.smithy.rust.codegen.server.smithy.testutil.serverIntegrationTest + +/** + * Test to verify AwsJson protocols compile correctly with streaming operations. + * + * This test ensures that the ResponseRejection enum in aws_json protocol + * has proper From implementations for BuildError, which is needed when + * serializing HTTP payloads for streaming operations. + */ +internal class AwsJsonCompilationTest { + @ParameterizedTest + @EnumSource( + value = ModelProtocol::class, + names = ["AwsJson10", "AwsJson11"], + ) + fun `AwsJson protocols should compile with streaming operations`(protocol: ModelProtocol) { + val (model) = loadSmithyConstraintsModelForProtocol(protocol) + serverIntegrationTest( + model, + IntegrationTestParams( + additionalSettings = + ServerAdditionalSettings.builder() + .publicConstrainedTypes(true) + .generateCodegenComments(true) + .toObjectNode(), + ), + ) { _, _ -> + // Test passes if code generation and compilation succeed + } + } +} diff --git a/rust-runtime/aws-smithy-http-server/Cargo.toml b/rust-runtime/aws-smithy-http-server/Cargo.toml index 456fb88099c..2c81a29c9d7 100644 --- a/rust-runtime/aws-smithy-http-server/Cargo.toml +++ b/rust-runtime/aws-smithy-http-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aws-smithy-http-server" -version = "0.65.8" +version = "0.65.9" authors = ["Smithy Rust Server "] edition = "2021" license = "Apache-2.0" diff --git a/rust-runtime/aws-smithy-http-server/src/protocol/aws_json/rejection.rs b/rust-runtime/aws-smithy-http-server/src/protocol/aws_json/rejection.rs index b3bc24fae25..7a199a536f5 100644 --- a/rust-runtime/aws-smithy-http-server/src/protocol/aws_json/rejection.rs +++ b/rust-runtime/aws-smithy-http-server/src/protocol/aws_json/rejection.rs @@ -9,6 +9,8 @@ use thiserror::Error; #[derive(Debug, Error)] pub enum ResponseRejection { + #[error("error building HTTP response: {0}")] + Build(#[from] aws_smithy_types::error::operation::BuildError), #[error("error serializing JSON-encoded body: {0}")] Serialization(#[from] aws_smithy_types::error::operation::SerializationError), #[error("error building HTTP response: {0}")]