smithy-lang / smithy-dafny

Apache License 2.0
9 stars 8 forks source link

Standardize validation error text across target languages? #611

Open robin-aws opened 2 weeks ago

robin-aws commented 2 weeks ago

Spin-off from https://github.com/smithy-lang/smithy-dafny/pull/582#discussion_r1773676073

Polymorph generally evaluates constraints "on the client side", i.e. in the target language rather than the source language. That means unlike with a real microservice, the exact error messages can be different.

On the one hand, we've seen any variation can be cause for alarm when trying to assert that a polymorphed library behaves identically to the original: https://github.com/smithy-lang/smithy-dafny/issues/362

On the other hand, having the validation in each target language means the error text can be slightly more tuned to that language, which is better UX: "The full_name field must be set - call .set_full_name(...) on the builder" (using e.g. Rust terms and concrete symbols) as opposed to "The FullName member must be present" (generic validation on the server side, has to use generic Smithy terms)

robin-aws commented 6 days ago

Relevant: Smithy now includes a built-in error shape for validation exceptions, smithy.framework#ValidationException. See https://smithy.io/2.0/tutorials/full-stack-tutorial.html#generating-the-server-sdk