Automatically add smithy.framework#ValidationException to constrained operations#4506
Automatically add smithy.framework#ValidationException to constrained operations#4506ysaito1001 merged 17 commits intomainfrom
smithy.framework#ValidationException to constrained operations#4506Conversation
Previously, users had to set `addValidationExceptionToConstrainedOperations: true` or manually add ValidationException to each operation with constrained inputs. Now ValidationException is automatically added unless a custom validation exception (with @validationException trait) exists in the model. - Change `addValidationExceptionToConstrainedOperations` from Boolean to nullable - Detect custom validation exceptions via @validationException trait - Skip automatic addition when custom validation exception is defined - Add deprecation warning when flag is explicitly set to true - Update tests to verify automatic and custom validation behavior - Update AGENTS.md with codegen settings documentation
| /** | ||
| * @deprecated This flag is deprecated. `smithy.framework#ValidationException` is now automatically added to operations | ||
| * with constrained inputs unless a custom validation exception (a structure with the `@validationException` | ||
| * trait) is defined in the model. Setting this to false will disable the automatic addition, but this | ||
| * behavior is deprecated and may be removed in a future release. | ||
| */ | ||
| val addValidationExceptionToConstrainedOperations: Boolean? = null, |
There was a problem hiding this comment.
what if a constraint trait is removed? Does that cause a breaking change in clients? Not sure we need to worry about it but worth considering. I guess validation exception is "hidden" in that only the server actually cares about it?
33d0826 to
a21564a
Compare
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
As an additional (interactive) test, let's make sure that the changes pass |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
As detailed in #3813, each event stream operation must have ValidationException attached. This is necessary because when an operation's input includes an event streaming member, the builder for the operation input or output can raise a ConstraintViolation if build_enforcing_all_constraints is called and the event streaming member field has not been set.
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
Looks like the current HEAD |
I'm investigating the issue now and will push a fix once I identify the root cause. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
|
A new generated diff is ready to view.
A new doc preview is ready to view. |
## Motivation and Context P382257849 ## Description Changes on the client side: - [x] Remove extra rest json tests that are officially part of Smithy protocol tests in 1.64.0 - [x] Filter out newly added model in `SmithyTypesPubUseExtraTest.kt` that would otherwise defeat the purpose of the test Changes on the server side: - [x] Address errors related to server's constraint types (#4506) - [x] #4535 - [x] #4537 ## Testing - CI ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._ --------- Co-authored-by: Fahad Zubair <fahadzubair@gmail.com> Co-authored-by: Fahad Zubair <fahadzub@amazon.com>
Previously, users had to set
addValidationExceptionToConstrainedOperations: trueor manually add ValidationException to each operation with constrained inputs.
Now ValidationException is automatically added unless a custom validation exception
(with @validationException trait) exists in the model.
addValidationExceptionToConstrainedOperationsfrom Boolean to nullableCloses: 4494