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

Flag enum insertions as errors #873

Merged
merged 2 commits into from
Aug 2, 2021
Merged

Flag enum insertions as errors #873

merged 2 commits into from
Aug 2, 2021

Conversation

ianbotsf
Copy link
Contributor

Issue #, if available:

(none)

Description of changes:

When calculating Smithy diffs, enum value insertions should be flagged as errors because they can cause backwards incompatibility concerns when enum ordinals are used for iterating, serialization, etc. Enum values appended to the end of the existing set of values should not be errors.

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

When calculating Smithy diffs, enum value insertions should be flagged
as errors because they can cause backwards incompatibility concerns when
enum ordinals are used for iterating, serialization, etc. Enum values
appended to the end of the existing set of values should not be errors.
* enum value is removed, and emits an ERROR when an enum name changes.
* Emits a NOTE when a new enum value is appended, emits an ERROR when an
* enum value is removed, emits an ERROR when an enum name changes, and
* emits an ERROR when a new enum value is inserted.
Copy link
Member

Choose a reason for hiding this comment

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

Throughout this PR, can we be more specific about what inserted means? We mean that an enum value was added but not at the end of the list of enum values. I think clarifying with this little tweak will save countless hours of teams not understanding the error.

"Enum value `%s` was added", definition.getValue())));
if (newPosition <= oldEndPosition) {
events.add(error(change.getNewShape(), String.format(
"Enum value `%s` was inserted. This can cause compatibility issues when ordinal values are "
Copy link
Member

Choose a reason for hiding this comment

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

I love the extra bit of context here about why this matters! Can you say something like "Enum value %s was inserted, but not at the end of the list of existing enum values. [...]" or something to that effect?

@mtdowling mtdowling merged commit 08c827a into smithy-lang:main Aug 2, 2021
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.

2 participants