Skip to content

Automatically add smithy.framework#ValidationException to constrained operations#4506

Merged
ysaito1001 merged 17 commits intomainfrom
fahadzub/add-validation-auto
Feb 13, 2026
Merged

Automatically add smithy.framework#ValidationException to constrained operations#4506
ysaito1001 merged 17 commits intomainfrom
fahadzub/add-validation-auto

Conversation

@drganjoo
Copy link
Contributor

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

Closes: 4494

  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
@drganjoo drganjoo requested review from a team as code owners January 28, 2026 17:35
Comment on lines +111 to +117
/**
* @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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@drganjoo drganjoo force-pushed the fahadzub/add-validation-auto branch from 33d0826 to a21564a Compare January 29, 2026 12:15
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Feb 5, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001
Copy link
Contributor

As an additional (interactive) test, let's make sure that the changes pass ./gradlew codegen-server-test:test for Smithy version 1.67.0.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

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.
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 mentioned this pull request Feb 12, 2026
5 tasks
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 enabled auto-merge February 12, 2026 23:17
@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001
Copy link
Contributor

Looks like the current HEAD e017301 never finishes check-server-codegen-unit-tests (ran it locally and didn't finish after 1 hour).

@drganjoo
Copy link
Contributor Author

Looks like the current HEAD e017301 never finishes check-server-codegen-unit-tests (ran it locally and didn't finish after 1 hour).

I'm investigating the issue now and will push a fix once I identify the root cause.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@ysaito1001 ysaito1001 merged commit a02bab9 into main Feb 13, 2026
50 checks passed
@ysaito1001 ysaito1001 deleted the fahadzub/add-validation-auto branch February 13, 2026 21:25
ysaito1001 added a commit that referenced this pull request Feb 16, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants