Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change to limit sets to string, blob, byte, short, integer, long, bigInteger, bigDecimal #1106

Merged
merged 2 commits into from
Feb 24, 2022

Conversation

mtdowling
Copy link
Member

@mtdowling mtdowling commented Feb 24, 2022

Sets can now only contain string, blob, byte, short, integer, long, bigInteger,
and bigDecimal shapes. Sets with other types of values are either difficult
to implement in various programming languages (for example, sets of floats in
Rust), or highly problematic for client/server use cases. Clients that are out
of sync with a service model could receive structures or unions from a
service, not recognize new members and drop them, causing the hash codes of
members of the set to collide, and this would result in the client discarding
set entries. For example, a service might return a set of 3 structures, but
when clients deserialize them, they drop unknown members, and the set
contains fewer than 3 entries.

Existing models that already use a set of other types will need to migrate to
use a list rather than a set, and they will need to implement any necessary
uniqueness checks server-side as needed.

While this is a breaking change, allowing sets to contain other types of values has proven to be an unsafe misfeature and something most clients have been unable to support (in fact, most Smithy implementations actually treat sets as lists in generated code).

Closes #1106
Closes #1093

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from a team as a code owner February 24, 2022 01:26
@mtdowling mtdowling changed the title Breaking Change to limit sets to only allow strings Breaking Change to limit sets to string, byte, short, integer, long, bigInteger, bigDecimal Feb 24, 2022
Copy link
Contributor

@adamthom-amzn adamthom-amzn left a comment

Choose a reason for hiding this comment

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

We deprecated @Uniqueitems but it isn't removed, should we restrict the types it can apply to as well?

@mtdowling mtdowling changed the title Breaking Change to limit sets to string, byte, short, integer, long, bigInteger, bigDecimal Breaking Change to limit sets to string, blob, byte, short, integer, long, bigInteger, bigDecimal Feb 24, 2022
Sets can now only contain string, blob, byte, short, integer, long, bigInteger,
and bigDecimal shapes. Sets with other types of values are either difficult
to implement in various programming languages (for example, sets of floats in
Rust), or highly problematic for client/server use cases. Clients that are out
of sync with a service model could receive structures or unions from a
service, not recognize new members and drop them, causing the hash codes of
members of the set to collide, and this would result in the client discarding
set entries. For example, a service might return a set of 3 structures, but
when clients deserialize them, they drop unknown members, and the set
contains fewer than 3 entries.

Existing models that already use a set of other types will need to migrate to
use a list rather than a set, and they will need to implement any necessary
uniqueness checks server-side as needed.

Support blob sets, do spec and validation cleanup
@mtdowling
Copy link
Member Author

Sure, I can adjust uniqueItems too given it's deprecated and we will not allow it's use in IDL v2.

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.

Exclude some types (e.g. floating point types) from @uniqueItems lists
3 participants