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

Mismatch in Error Code Handling in Generated Waiter Functions #1283

Open
RanVaknin opened this issue May 15, 2024 · 0 comments
Open

Mismatch in Error Code Handling in Generated Waiter Functions #1283

RanVaknin opened this issue May 15, 2024 · 0 comments

Comments

@RanVaknin
Copy link
Contributor

Issue Description:

There is a discrepancy in how Smithy TypeScript generates waiter functions to handle error codes and their corresponding modeled exceptions. The issue arises because the generated TypeScript code uses the name property of the exception to match errors, but the actual error names returned by AWS differ from the error codes defined in the Smithy model.
Root cause is likely that the WaiterGenerator.java code refers to error.name, whereas awsQueryError needs proper matching.

Example

The Smithy model might define an error with the awsQueryError code DBInstanceNotFound, but the actual exception name returned by AWS is DBInstanceNotFoundFault. This leads to incorrect error matching in the generated code, causing waiter functions to either hang indefinitely or fail to transition correctly when the desired resource state is reached.

Smithy model definition:

"com.amazonaws.rds#DBInstanceNotFoundFault": {
  "type": "structure",
  "members": {
    "message": {
      "target": "com.amazonaws.rds#ExceptionMessage"
    }
  },
  "traits": {
    "aws.protocols#awsQueryError": {
      "code": "DBInstanceNotFound",
      "httpResponseCode": 404
    },
    "smithy.api#documentation": "<p>DBInstanceIdentifier doesn't refer to an existing DB instance.</p>",
    "smithy.api#error": "client",
    "smithy.api#httpError": 404
  }
}

Generated TypeScript code:

if (exception.name && exception.name == "DBInstanceNotFound") {
  return { state: "SUCCESS" };
}

Expected Behavior:

The waiter function should correctly recognize the DBInstanceNotFoundFault exception and transition to the success state.

Current Behavior:

The waiter function fails to recognize the DBInstanceNotFoundFault exception, causing it to either hang indefinitely or not transition correctly.

related issue aws/aws-sdk-js-v3#6084

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