Skip to content

Commit 5712eed

Browse files
author
Fahad Zubair
committed
Rebase with main
1 parent 1cb98c6 commit 5712eed

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

.changelog/1738663351.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
applies_to:
3+
- server
4+
authors:
5+
- drganjoo
6+
references: []
7+
breaking: false
8+
new_feature: true
9+
bug_fix: false
10+
---
11+
Allow invalid UTF-8 characters to be replaced with �

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/parse/JsonParserGenerator.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class JsonParserGenerator(
101101
ReturnSymbolToParse(codegenContext.symbolProvider.toSymbol(shape), false)
102102
},
103103
private val customizations: List<JsonParserCustomization> = listOf(),
104-
smithyJson: RuntimeType = RuntimeType.smithyJson(codegenContext.runtimeConfig),
104+
smithyJsonWithFeatureFlag: RuntimeType = RuntimeType.smithyJson(codegenContext.runtimeConfig),
105105
) : StructuredDataParserGenerator {
106106
private val model = codegenContext.model
107107
private val symbolProvider = codegenContext.symbolProvider
@@ -111,20 +111,20 @@ class JsonParserGenerator(
111111
private val builderInstantiator = codegenContext.builderInstantiator()
112112
private val codegenScope =
113113
arrayOf(
114-
"Error" to smithyJson.resolve("deserialize::error::DeserializeError"),
115-
"expect_blob_or_null" to smithyJson.resolve("deserialize::token::expect_blob_or_null"),
116-
"expect_bool_or_null" to smithyJson.resolve("deserialize::token::expect_bool_or_null"),
117-
"expect_document" to smithyJson.resolve("deserialize::token::expect_document"),
118-
"expect_number_or_null" to smithyJson.resolve("deserialize::token::expect_number_or_null"),
119-
"expect_start_array" to smithyJson.resolve("deserialize::token::expect_start_array"),
120-
"expect_start_object" to smithyJson.resolve("deserialize::token::expect_start_object"),
121-
"expect_string_or_null" to smithyJson.resolve("deserialize::token::expect_string_or_null"),
122-
"expect_timestamp_or_null" to smithyJson.resolve("deserialize::token::expect_timestamp_or_null"),
123-
"json_token_iter" to smithyJson.resolve("deserialize::json_token_iter"),
114+
"Error" to smithyJsonWithFeatureFlag.resolve("deserialize::error::DeserializeError"),
115+
"expect_blob_or_null" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_blob_or_null"),
116+
"expect_bool_or_null" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_bool_or_null"),
117+
"expect_document" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_document"),
118+
"expect_number_or_null" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_number_or_null"),
119+
"expect_start_array" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_start_array"),
120+
"expect_start_object" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_start_object"),
121+
"expect_string_or_null" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_string_or_null"),
122+
"expect_timestamp_or_null" to smithyJsonWithFeatureFlag.resolve("deserialize::token::expect_timestamp_or_null"),
123+
"json_token_iter" to smithyJsonWithFeatureFlag.resolve("deserialize::json_token_iter"),
124124
"Peekable" to RuntimeType.std.resolve("iter::Peekable"),
125-
"skip_value" to smithyJson.resolve("deserialize::token::skip_value"),
126-
"skip_to_end" to smithyJson.resolve("deserialize::token::skip_to_end"),
127-
"Token" to smithyJson.resolve("deserialize::Token"),
125+
"skip_value" to smithyJsonWithFeatureFlag.resolve("deserialize::token::skip_value"),
126+
"skip_to_end" to smithyJsonWithFeatureFlag.resolve("deserialize::token::skip_to_end"),
127+
"Token" to smithyJsonWithFeatureFlag.resolve("deserialize::Token"),
128128
"or_empty" to orEmptyJson(),
129129
*preludeScope,
130130
)

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocol.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,15 @@ fun jsonParserGenerator(
145145
listOf(
146146
ServerRequestBeforeBoxingDeserializedMemberConvertToMaybeConstrainedJsonParserCustomization(codegenContext),
147147
) + additionalParserCustomizations,
148-
smithyJson,
148+
smithyJsonWithFeatureFlag =
149+
if (codegenContext.settings.codegenConfig.replaceInvalidUtf8) {
150+
CargoDependency.smithyJson(codegenContext.runtimeConfig)
151+
.copy(features = setOf("replace-invalid-utf8"))
152+
.toType()
153+
} else {
154+
RuntimeType.smithyJson(codegenContext.runtimeConfig)
155+
},
156+
,
149157
)
150158

151159
class ServerAwsJsonProtocol(

rust-runtime/aws-smithy-json/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "aws-smithy-json"
3-
version = "0.61.2"
3+
version = "0.62.0"
44
authors = [
55
"AWS Rust SDK Team <[email protected]>",
66
"John DiSanti <[email protected]>",

0 commit comments

Comments
 (0)