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

[Bug] AWS SDK regression for InvalidEndpiont #680

Open
texastony opened this issue Nov 4, 2024 · 0 comments
Open

[Bug] AWS SDK regression for InvalidEndpiont #680

texastony opened this issue Nov 4, 2024 · 0 comments

Comments

@texastony
Copy link
Contributor

InvalidEndpoint present in SDK Models but not in packages

The InvalidEndpointException is occasionally present in AWS SDK Models,
such as DynamoDB's (link to shape in TestModel).

But the AWS SDK for Java V2 does not include this Exception.
It is hard to find linkable evidence,
but you can check the JavaDoc for the DDB Package's Model section
and see that it is not present
.

Smithy-Dafny has many hard-coded checks for this,
to prevent consumers from getting a Class Not Found exception or it's .NET allegory.

But those hard-coded checks are not applied on the "all error" converter.

For a list of those hard-coded checks:

grep -n "InvalidEndpoint" codegen/**/*.java
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/AwsSdkTypeConversionCodegen.java:172:            // InvalidEndpointException does not exist in v2 of the sdk
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/AwsSdkTypeConversionCodegen.java:173:            if (sdkErrorType.endsWith("InvalidEndpointException")) {
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/AwsSdkTypeConversionCodegen.java:211:              modeledErrorShapeId.getName().endsWith("InvalidEndpointException")
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java:1951:    // InvalidEndpointException was deprecated in v3 of the dynamodb sdk for net
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithydotnet/TypeConversionCodegen.java:1955:        "Amazon.DynamoDBv2.Model.InvalidEndpointException"
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ShimV2.java:216:        // InvalidEndpointException was removed in SDK V2
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ShimV2.java:217:        if (typeForShape.toString().endsWith("InvalidEndpointException")) {
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ToDafnyAwsV2.java:128:      // InvalidEndpointException does not exist in SDK V2
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ToDafnyAwsV2.java:132:          .contains("com.amazonaws.dynamodb#InvalidEndpointException")
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ToNativeAwsV2.java:152:      // InvalidEndpointException does not exist in SDK V2
codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyjava/generator/awssdk/v2/ToNativeAwsV2.java:156:          .contains("com.amazonaws.dynamodb#InvalidEndpointException")

Consequence

The result of this miss MAY be a risk to Java consumers.

For Errors, the Java conversion logic uses overloaded methods,
all with the same name, Error,
relying on type refinement/checking to invoke the correct method.

Because there will be no refinement for InvalidEndpoint,
the Error conversion method MAY recursively call the generic method.

Alternatively, it may end up at Opaque.
I am not certain.

See https://github.com/aws/aws-cryptographic-material-providers-library/pull/947/files#diff-010f7297293a5a90e7b1dcf3e0ab959b6410315786912f3ecafb87fc5627a140 for an example that added this problematic issue.

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

No branches or pull requests

1 participant