HeadspaceMeditation / beyonce

Type-safe DynamoDB query builder for TypeScript. Designed with single-table architecture in mind.
Apache License 2.0
6 stars 5 forks source link

feat!: upgrade AWS SDK to v3 #83

Open gbryan opened 2 years ago

gbryan commented 2 years ago

Ticket: https://app.asana.com/0/1200444444072189/1202815880040240

We will not yet merge this because we cannot upgrade Beyonce's AWS SDK to v3 without also upgrading Vault's. Timeboxing Vault's AWS SDK to v3 to 30 minutes indicated that it isn't as quick enough a task that we can take it on right now. We can pick that up (and also merge + test E2E this PR) in the future within one of our teams' tech debt budgets.


This PR upgrades Beyonce from v2 to v3 of the AWS SDK, which involves breaking changes: clients need to instantiate Beyonce with a DynamoDB instance from @aws-sdk/client-dynamodb v3 instead of aws-sdk v2.

Reviewing commit-by-commit will be easiest.

The original motivation for this upgrade was to experiment with the new error responses from DynamoDB when encountering a condition check failure while executing a transaction, to see if the new error messages provide enough detail to determine which condition check failed (so we could distinguish the reason(s) in the case that there were to be multiple condition checks). Related ticket. It turns out that even the new v3 error responses do not contain such detail. For example, here's an error:

    TransactionCanceledException: Transaction cancelled, please refer cancellation reasons for specific reasons [None, ConditionalCheckFailed]
        at deserializeAws_json1_0TransactionCanceledExceptionResponse (/Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3072:23)
        at deserializeAws_json1_0TransactWriteItemsCommandError (/Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:2380:25)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at /Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
        at /Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:11:20
        at StandardRetryStrategy.retry (/Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/middleware-retry/dist-cjs/StandardRetryStrategy.js:51:46)
        at /Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:6:22
        at /Users/bryangaston/workspace/gingerio/beyonce/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/TransactWriteCommand.js:36:26 {
      '$fault': 'client',
      '$metadata': {
        httpStatusCode: 400,
        requestId: 'e3e60378-8cbf-44b4-9a8c-15869adec843',
        extendedRequestId: undefined,
        cfId: undefined,
        attempts: 1,
        totalRetryDelay: 0
      },
      CancellationReasons: [
        { Code: 'None', Item: undefined, Message: undefined },
        {
          Code: 'ConditionalCheckFailed',
          Item: undefined,
          Message: 'The conditional request failed'
        }
      ],
      __type: 'com.amazonaws.dynamodb.v20120810#TransactionCanceledException'
    }