aws-sdk-rust icon indicating copy to clipboard operation
aws-sdk-rust copied to clipboard

[request] Make way fewer things Option<T> types

Open rickwebiii opened this issue 3 years ago • 3 comments
trafficstars

Describe the feature

In the model types for each API (e.g. ec2), nearly every field is Option<T>. This means that developers have to make a bunch of boilerplate error handling by calling unwrap_or_default, ok_or, etc.

I expect that many fields are actually guaranteed to exist when making calls. For example, when calling ec2_client.describe_instances, every Instance should always have an instance_id. Otherwise, how would ever do anything with it?

This feature request is to comb through all the APIs and only use Option<T> on values that aren't guaranteed to exist.

Use Case

This significantly reduces the amount of boilerplate error handling needed around errors that should never occur.

Proposed Solution

Only mark truly optional fields and types as Option<T> and update all the builder() calls to accept required fields as parameters.

Other Information

This feature will definitely be a breaking change.

Acknowledgements

  • [ ] I may be able to implement this feature request
  • [X] This feature might incur a breaking change

A note for the community

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue, please leave a comment

rickwebiii avatar May 17 '22 23:05 rickwebiii

Thanks for filing!

This is definitely something we want to improve, and we're hoping to make many of these optional fields required prior to GA.

See also the discussion in https://github.com/awslabs/aws-sdk-rust/discussions/163

jdisanti avatar May 18 '22 00:05 jdisanti

Awesome, good to hear!

rickwebiii avatar May 19 '22 17:05 rickwebiii

Smithy IDL 2.0 now makes it possible to reduce the number of optional types, and our code generator has been updated to support it. I think we just need to modify the code generator to query Smithy's NullableIndex to determine which members can have the Options removed. We're getting closer! 😄

jdisanti avatar Aug 31 '22 18:08 jdisanti

This will go out with the next big release (it will be announced in the release notes when it is, so if there are other releases before it, it is not in those).

jdisanti avatar Oct 05 '23 16:10 jdisanti

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Nov 02 '23 19:11 github-actions[bot]