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

lib-dynamodb v3.666.0 throws error on getting database data (possible regression) #6549

Closed
4 tasks done
samuel-pipelaunch opened this issue Oct 7, 2024 · 15 comments
Closed
4 tasks done
Assignees
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@samuel-pipelaunch
Copy link

Checkboxes for prior research

Describe the bug

Was working perfectly before updating to the latest version.
Now throws error each time I want to read a value from a dynamoDB

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node v20

Reproduction Steps

  • Install the version v3.666.0
  • Compile with serverless-esbuild": "^1.54.3
  • Try to read data const res = await ddbClient.send(new GetCommand(params));

Observed Behavior

TypeError: (0 , import_core29.setFeature) is not a function  at <anonymous> (/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:147:25)  at <anonymous> (/node_modules/@aws-sdk/client-dynamodb/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:28)  at <anonymous> (/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:490:24)   at _DynamoDBClient.send (/node_modules/@aws-sdk/client-dynamodb/node_modules/@smithy/smithy-client/dist-cjs/index.js:126:14)

Expected Behavior

Do not throw errors

Possible Solution

No response

Additional Information/Context

No response

@samuel-pipelaunch samuel-pipelaunch added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 7, 2024
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Oct 7, 2024
@aBurmeseDev aBurmeseDev self-assigned this Oct 7, 2024
@aBurmeseDev aBurmeseDev added investigating Issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 7, 2024
@aBurmeseDev
Copy link
Member

Hi @samuel-pipelaunch - thanks for reaching out.

While I look further into investigating this, could you share a minimal reproducible SDK code you have? What was the pervious working version for you before version upgrade? Knowing the previous working version can help us pinpoint the changes introduced in the latest version that might be causing the incompatibility.

@aBurmeseDev aBurmeseDev added the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Oct 8, 2024
@sporto
Copy link

sporto commented Oct 8, 2024

Seeing the same

@samuel-pipelaunch
Copy link
Author

What was the pervious working version for you before version upgrade?

It was working on this version:
"@aws-sdk/lib-dynamodb": "^3.654.0"

@aBurmeseDev
Copy link
Member

It seems that the error you're seeing is likely due to a version mismatch between the @aws-sdk/lib-dynamodb and @aws-sdk/client-dynamodb packages. The @aws-sdk/lib-dynamodb package has a peer dependency on @aws-sdk/client-dynamodb, but it's not locked to a specific version.

To confirm the root cause, you need to check the versions of these two packages in your package.json file. The @aws-sdk/lib-dynamodb package requires a certain minimum version of @aws-sdk/client-dynamodb to work correctly.

The potential solution is to ensure that you have a valid combination of versions for these two packages. You can achieve this by setting the version range to be less than or equal to the version you're using for @aws-sdk/lib-dynamodb (in your case, "<=3.666.0").

We have verified and confirmed that the solution provided works on our end, but if issue persists, please share package.json or list of dependencies along with minimal repro code snippet.

Hope it helps!

@aBurmeseDev aBurmeseDev removed the investigating Issue is being investigated and/or work is in progress to resolve the issue. label Oct 8, 2024
@sporto
Copy link

sporto commented Oct 8, 2024

We are seeing this error when having @aws-sdk/[email protected]

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Oct 9, 2024
@rowanmanning
Copy link

We are still seeing this error. Our app is running:

@aws-sdk/client-dynamodb	v3.667.0
@aws-sdk/lib-dynamodb		v3.667.0

I checked our package-lock.json file and every single @aws-sdk package we're installing is v3.667.0.

@aBurmeseDev aBurmeseDev added the p2 This is a standard priority issue label Oct 9, 2024
@jerizm
Copy link
Contributor

jerizm commented Oct 9, 2024

Could it be as simple as lib-dynamodb is missing a dependency on @aws-sdk/core?

https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-dynamodb/src/baseCommand/DynamoDBDocumentClientCommand.ts#L1

import { setFeature } from "@aws-sdk/core";

https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-dynamodb/package.json#L28-L34

  "dependencies": {
    "@aws-sdk/util-dynamodb": "*",
    "@smithy/core": "^2.4.8",
    "@smithy/smithy-client": "^3.4.0",
    "@smithy/types": "^3.5.0",
    "tslib": "^2.6.2"
  },

@mjeanroy
Copy link

mjeanroy commented Oct 10, 2024

I had the same and tried to understood: it looks like @aws-sdk/lib-dynamodb uses the setFeature from @aws-sdk/core introduced in version 3.664.0.

As @jerizm said, the dependency on @aws-sdk/core ^3.664.0 is not declared in @aws-sdk/lib-dynamodb. It means that @aws-sdk/lib-dynamodb will resolved the one found in your node_modules tree.

If, for some reason, it founds a version of @aws-sdk/core < 3.664, then this error appears :/

You can check why outdated version of @aws-sdk/core are imported using npm ls @aws-sdk/core or (yarn why @aws-sdk/core or pnpm why @aws-sdk/core depending on which package manager you use). Then, you should be able to understand where it's coming from.

@aBurmeseDev
Copy link
Member

Hello everyone, I appreciate your responses. However, I'm unable to reproduce the issue on my end. Could someone provide a reproducible code snippet along with detailed steps? That would be really helpful.

Here are the steps I've taken:

  • installed the latest versions of the @aws-sdk/lib-dynamodb and @aws-sdk/client-dynamodb packages using npm.
  • created a test DynamoDB table named "cities" and added an item with the key "Los Angeles".
  • ran the following code snippet, and it successfully retrieved the item from the table.

code example

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand } from "@aws-sdk/lib-dynamodb";

const client = new DynamoDBClient({ region: "us-west-1" });
const docClient = DynamoDBDocumentClient.from(client);

export const main = async () => {
  const command = new GetCommand({
    TableName: "cities",
    Key: {
        cityName: "Los Angeles",
    },
  });

  const response = await docClient.send(command);
  console.log(response);
  return response;
};

main();

response

{
  '$metadata': {
    httpStatusCode: 200,
    requestId: 'ABLUVICAU2M2QQOMLGLFO22N47VV4KQNSO5AEMVJF66Q9ASUAAJG',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Item: { cityName: 'Los Angeles' }
}
  "dependencies": {
    "@aws-sdk/client-dynamodb": "^3.668.0",
    "@aws-sdk/lib-dynamodb": "^3.668.0"
  }

Any further details you can provide would be greatly appreciated!

@aBurmeseDev aBurmeseDev added the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Oct 10, 2024
@jerizm
Copy link
Contributor

jerizm commented Oct 10, 2024

Any further details you can provide would be greatly appreciated!

You can install @aws-sdk/[email protected] to replicate. Because lib-dynamodb does not have its own dependency on @aws-sdk/core it will use that version which doesn't have setFeature

❯ npm i @aws-sdk/[email protected]
❯ node index.js
/Users/jerry/git/example/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:147
        (0, import_core.setFeature)(context, "DDB_MAPPER", "d");
                                   ^

TypeError: (0 , import_core.setFeature) is not a function
    at /Users/jerry/git/example/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:147:36
    at /Users/jerry/git/example/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:28
    at /Users/jerry/git/example/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/index.js:490:24
    at _DynamoDBDocumentClient.send (/Users/jerry/git/example/node_modules/@smithy/smithy-client/dist-cjs/index.js:126:14)
    at main (file:///Users/jerry/git/example/index.js:15:38)
    at file:///Users/jerry/git/example/index.js:20:1
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

That being said. It should be fixed after this is merged. #6557

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. label Oct 11, 2024
@aBurmeseDev
Copy link
Member

@jerizm - PR (#6557) has been merged and was released about 3 days ago. Please let us know if there's anything else we could address.

@aBurmeseDev aBurmeseDev added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Oct 14, 2024
@nelmasry
Copy link

@aBurmeseDev it is now solved when updating to "@aws-sdk/lib-dynamodb": "^3.670.0"
Thanks for your support.

@jerizm
Copy link
Contributor

jerizm commented Oct 14, 2024

@aBurmeseDev Thanks for the help. The issue is now resolved.

@samuel-pipelaunch
Copy link
Author

Thank you very much @aBurmeseDev

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue is a bug. closing-soon This issue will automatically close in 4 days unless further comments are made. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

No branches or pull requests

7 participants