aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.14k stars 580 forks source link

DynamoDB SDK missing the ValidationException class #6696

Open alfaproject opened 6 days ago

alfaproject commented 6 days ago

Describe the feature

For some reason, DynamoDB SDK is missing the ValidationException class from the exported exception classes which goes against the philosophy of the new SDK

Use Case

Consistency with checking exception types:

if (error instanceof ConditionalCheckFailedException || error.name === 'ValidationException') {
}

Proposed Solution

Create the ValidationException class and export it

Other Information

No response

Acknowledgements

SDK version used

Latest

Environment details (OS name and version, etc.)

Linux

alfaproject commented 6 days ago

This is a duplicate of https://github.com/aws/aws-sdk-js-v3/issues/3618 and I'm not really sure why that was closed. This is still an issue and inconsistent...

RanVaknin commented 6 days ago

Hi @alfaproject ,

I'm not really sure why that was closed.

It was closed because the original poster closed it.

For some reason, DynamoDB SDK is missing the ValidationException class from the exported exception classes which goes against the philosophy of the new SDK

The reason the DynamoDB SDK is missing the ValidationException class is because the SDK is code-generated from the API model definition of the Dynamodb service, which lacks this exception definition. You can see the generated dynamodb API docs do not have ValidationException listed under the list of common errors https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/CommonErrors.html

You can check the model file the SDK is generated from and see that the validation exception is indeed missing.

The SDK team cannot "Add" that missing exception class because it must be added by the dynamodb service team itself first. Instead, I have reached out to the DDB team internally (ticket ID #P173513119) and asked them to add the exception in question to their model file so the SDK can get generated with the exception in question. If you have access to AWS support, you can open your own support ticket and reference the ticket I have created for more visibility.

In the meantime, it's safe to use error.name === "ValidationException".

Thanks, Ran~

alfaproject commented 6 days ago

Thank you for looking into this and reaching out to DDB team.

Couple of questions tho, if those errors are common and shared with different (all?) services, shouldn't they be abstracted away from each individual service into some common package?

That linked page to the common errors has ValidationError as opposed to ValidationException. Not sure if it matters, but just wanted to point it out