-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for custom default values
This commit updates Smithy IDL v2 to support custom default values rather than only default zero values. We didn't previoulsy support custom default values because we wanted to be able to change default values if ever needed, we wanted to avoid information disclosure of unreleased internal members, and we wanted clients to be able to fill in a default zero value if a required member is missing on the wire (implying that the member transitioned from required to default). While default zero values are a big simplification for clients, they do come with awkward tradeoffs. For example, the zero value of an enum was `""` (or it could have been the first enum in the shape definition but that's problematic due to model filtering, and it requires a lot of up-front planning from service teams). We also observed that there are likely 1,000+ members already used in AWS that have default values that are only captured through documentation. If we could actually model defaults, it would be easier to catch changes to default values in automated diff tools and discuss them in API reviews. To address these concerns and support custom default values, we recommend the following: * clients implement presence tracking and only serialize default values if the member is explicitly set to the default value. This allows services to change defaults if ever necessary. * servers always serialize default values unless the member is marked with the `@internal` trait. This makes it explicit as to what the server thinks the default value is while still preventing unintended information disclosure of unreleased features. * To avoid downtime and account for misconfigured servers that do not serialize required or default members, clients attempt to populate the member with a default zero value. More details and specifics can be found in defaults-and-model-evolution.md. Enum changes: * Given the addition of syntax sugar for assigning values to defaulted structure members, this commit also allows syntactic sugar for assigning values to enum and intEnum shapes without the use of the `@enumValue` trait. * Now that there is no default zero value for enums, the `@enumDefault` trait has been removed.
- Loading branch information
Showing
128 changed files
with
2,190 additions
and
1,863 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
docs/source/1.0/spec/aws/aws-default-zero-value.rst.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
#. To avoid information disclosure, serializers SHOULD omit the default zero | ||
value of structure members marked with the :ref:`default-trait`. | ||
#. Deserializers MUST tolerate receiving the default zero value of a structure | ||
member marked with the :ref:`default-trait`. | ||
#. Client deserializers MUST fill in a default zero value for structure members | ||
marked with the :ref:`required-trait` that have no serialized value, and the | ||
targeted shape supports zero values. This prevents older clients from | ||
failing to deserialize structures at runtime when the :ref:`required-trait` | ||
is replaced with the :ref:`default-trait`. | ||
#. To avoid information disclosure, serializers SHOULD omit the default | ||
value of structure members that are marked with the :ref:`internal-trait`. | ||
#. Deserializers MUST tolerate receiving the default value of a structure | ||
member. | ||
#. Client deserializers SHOULD fill in a default zero value for structure | ||
members marked with the :ref:`required-trait` that have no serialized | ||
value, and the targeted shape supports zero values. While the server is | ||
in error, it does allow clients to function in the event a service is | ||
miconfigured. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.