diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt index 7d07ed90f4..d3f46439c0 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt @@ -389,8 +389,22 @@ class JsonParserGenerator( withBlock("let value =", ";") { deserializeMember(shape.member) } - rustBlock("if let Some(value) = value") { - rust("items.push(value);") + rust( + """ + if let Some(value) = value { + items.push(value); + } + """, + ) + codegenTarget.ifServer { + rustTemplate( + """ + else { + return Err(#{Error}::custom("dense list cannot contain null values")); + } + """, + *codegenScope, + ) } } } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 5492c75140..b378415051 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -773,7 +773,6 @@ class ServerProtocolTestGenerator( FailingTest(RestJson, "RestJsonEndpointTraitWithHostLabel", TestType.Request), FailingTest(RestJson, "RestJsonWithBodyExpectsApplicationJsonContentType", TestType.MalformedRequest), - FailingTest(RestJson, "RestJsonBodyMalformedListNullItem", TestType.MalformedRequest), // Deprioritized, sets don't exist in Smithy 2.0. // They have the exact same semantics as list shapes with `@uniqueItems`,