You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disallow ignoring a constrained shape in an event stream's closure (#2113)
The server SDK will otherwise produce Rust code that cannot be compiled,
so it doesn't make sense to prompt users to disregard the warning and
opt into `ignoreUnsupportedConstraints`. To continue synthesizing the
model, the user must remove any constrained traits from the event
stream's closure.
This commit also tweaks formatting of errors yielded by
`ValidateUnsupportedConstraints`. Prior to this commit, they were a bit
off due to carelessness when interpolation occurs. For example:
```
[SEVERE] Operation com.amazonaws.constraints#ConstrainedShapesOperation takes in input that is constrained(https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as such can fail with a validationexception. You must model this behavior in the operation shape in your model file.
```
Copy file name to clipboardExpand all lines: codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraints.kt
+21-13Lines changed: 21 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -37,15 +37,21 @@ private sealed class UnsupportedConstraintMessageKind {
Copy file name to clipboardExpand all lines: codegen-server/src/test/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ValidateUnsupportedConstraintsAreNotUsedTest.kt
@@ -56,7 +57,17 @@ internal class ValidateUnsupportedConstraintsAreNotUsedTest {
56
57
val validationResult = validateOperationsWithConstrainedInputHaveValidationExceptionAttached(model, service)
57
58
58
59
validationResult.messages shouldHaveSize 1
59
-
validationResult.messages[0].message shouldContain "Operation test#TestOperation takes in input that is constrained"
60
+
61
+
// Asserts the exact message, to ensure the formatting is appropriate.
62
+
validationResult.messages[0].message shouldBe """Operation test#TestOperation takes in input that is constrained (https://awslabs.github.io/smithy/2.0/spec/constraint-traits.html), and as such can fail with a validation exception. You must model this behavior in the operation shape in your model file.
fun`it should detect when the length trait on blob shapes is used`() {
172
198
val model =
@@ -183,7 +209,9 @@ internal class ValidateUnsupportedConstraintsAreNotUsedTest {
183
209
val validationResult = validateModel(model)
184
210
185
211
validationResult.messages shouldHaveSize 1
186
-
validationResult.messages[0].message shouldContain "The blob shape `test#LengthBlob` has the constraint trait `smithy.api#length` attached"
212
+
213
+
// This test additionally asserts the exact message, to ensure the formatting is appropriate.
214
+
validationResult.messages[0].message shouldBe "The blob shape `test#LengthBlob` has the constraint trait `smithy.api#length` attached. This is not supported in the smithy-rs server SDK. It will be supported in the future. See the tracking issue (https://github.com/awslabs/smithy-rs/issues/1401). If you want to go ahead and generate the server SDK ignoring unsupported constraint traits, set the key `ignoreUnsupportedConstraints` inside the `runtimeConfig.codegenConfig` JSON object in your `smithy-build.json` to `true`."
0 commit comments