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

Remove invalid defaults for some services #3217

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

milesziemer
Copy link
Contributor

Motivation and Context

Some services have generated types with properties that have a default value of zero. This can cause invalid requests if the service expects a value > 0.

Description

Adds a customization that removes the default value for services with this issue.

Testing

  • Added a test for the customization to make sure defaults were removed.
  • Generated clients for the impacted services and verified the expected types had the default value removed.

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@milesziemer milesziemer requested review from a team as code owners November 16, 2023 20:50
@milesziemer milesziemer force-pushed the add-remove-defaults-customization branch 4 times, most recently from 914cea3 to 3d2bb04 Compare November 16, 2023 21:21
Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

this seems more service specific? (in which case, we'd put in it in the service-specific decorator) but doesn't super matter. We should make sure we get examples updated in case this causes examples compilation issues.

Code is fine, just want to make sure we audit the generated code before landing.

Comment on lines 26 to 28
"com.amazonaws.emrserverless#AwsToledoWebService".shapeId() to setOf(
// Service expects this to have a min value > 0
"com.amazonaws.emrserverless#WorkerCounts".shapeId()
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we want to do it based on the range check? Or is hard coding it the right thing to do here?

Copy link
Contributor Author

@milesziemer milesziemer Nov 16, 2023

Choose a reason for hiding this comment

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

I thought about doing that. But my reasoning for not doing so was that since the range is wrong now, this will generate an Option<T>. Down the road, if the range check became not wrong, it would be a breaking change. So I think its best to just remove the default and always do it to be consistent. Comment is there just for context.

@milesziemer
Copy link
Contributor Author

this seems more service specific? (in which case, we'd put in it in the service-specific decorator) but doesn't super matter. We should make sure we get examples updated in case this causes examples compilation issues.

Code is fine, just want to make sure we audit the generated code before landing.

@rcoh This started out with quite a few more services, but by the time the PR was ready only one was left. I can update if need be though.

Adds a customization that removes default values, and uses it to
remove the default values for some shapes in certain services
that have a default value of 0, but the service expects a value
> 0.
@milesziemer milesziemer force-pushed the add-remove-defaults-customization branch from 3d2bb04 to 4ae08f1 Compare November 16, 2023 21:57
Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

LGTM—please just add TODO(<link to ticket in this repo): Remove this customizations after model updates

@milesziemer milesziemer force-pushed the add-remove-defaults-customization branch from bd9d122 to 7405fb9 Compare November 16, 2023 22:05
@rcoh rcoh enabled auto-merge November 17, 2023 02:20
@rcoh rcoh added this pull request to the merge queue Nov 17, 2023
Merged via the queue into smithy-lang:main with commit ad520b0 Nov 17, 2023
38 of 39 checks passed
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