-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix(go): enum and map in type conversion #782
Open
rishav-karanjit
wants to merge
11
commits into
main-1.x
Choose a base branch
from
go/enumfix
base: main-1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
if (this.isOptional) { | ||
someWrapIfRequired = "Wrappers.Companion_Option_.Create_Some_(%s)"; | ||
returnType = "Wrappers.Option"; | ||
// In AWS SDK, some shapes don't have required trait and also don't have pointers in it. | ||
// This will result the default value of the string be "" if not provided. | ||
noEnumMatchedCheck = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be defensive and error out in case of it being required and not matching an enum value.
There was a chance where this input could have been defaulted to a value. This specific case is also fine (in a wrong way but still fine.)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
Background: Some aws-sdk shapes can be non pointer variable even if it does not have a required trait.
Actual Issue:
""
because in Go default value for string is""
. However, if it defaults to""
, based on my type conversion function enum will be set to one of enum constant which is wrong.ToDafny
does isPointer check to do to do the nil check . However, mapShape never getsisPointer = True
because mapShape can be nil and is never generated with pointer. So, this isPointer check is never executed. Since, this isPointer check map defaults tomap[]
but it should default tonil
.Note:dafnyMap
is a structure which cannot be nil. So, this is generated as wrapper optional if its not required.Description of changes:
Callouts
MPL PR to see the diff: aws/aws-cryptographic-material-providers-library#1285
ESDK PR to see if the examples panics or not: aws/aws-encryption-sdk#754
This PR will brings code changes in MPL which is already released. But, this code change does not impact customer at all. The reason customer is not impact is because:
We take a specific shape (Like
com.amazonaws.dynamodb#TableName
) from customers but not the whole operation (likecom.amazonaws.dynamodb#GetItemInput
). So, we never use the function in type conversion layer that has been changed in MPL.We explicitly assign
None
those shapes which we don't use. So, we never allow the type conversion layer default value issue impact the customers. Examples of this:By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.