aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
2.96k stars 557 forks source link

(0 , import_core.parseJsonBody) is not a function #6116

Closed alexnatea closed 4 weeks ago

alexnatea commented 1 month ago

Checkboxes for prior research

Describe the bug

When migrating from

"@aws-sdk/client-dynamodb": "3.501.0",
"@aws-sdk/lib-dynamodb": "3.501.0",
"@aws-sdk/util-dynamodb": "3.501.0",

to

"@aws-sdk/client-dynamodb": "3.577.0",
"@aws-sdk/lib-dynamodb": "3.577.0",
"@aws-sdk/util-dynamodb": "3.577.0",

or any other version > 3.501.0, there is an error when using client-dynamodb

TypeError: (0 , import_core.parseJsonBody) is not a function Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.

SDK version number

@aws-sdk/client-dynamodb@3.577.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Reproduction Steps

just upgrading the package and running the app with local dynamodb docker

Observed Behavior

TypeError: (0 , import_core.parseJsonBody) is not a function Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.

resulting in 500 error status code from using DynamoDBDocumentClient from '@aws-sdk/lib-dynamodb' -> query command

Expected Behavior

to not throw 500 error and import_core.parseJsonBody to work

Possible Solution

No response

Additional Information/Context

No response

kuhe commented 1 month ago

what package is imported to the variable named import_core? and what is its version?

It should be @aws-sdk/core@3.576.0 which has the function.

Demo:

npm i @aws-sdk/core@"<=3.577.0"

added 33 packages, and audited 34 packages in 2s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
[kuhe]$ npm ls @aws-sdk/core
/folder/
└── @aws-sdk/core@3.576.0

[kuhe]$ node
Welcome to Node.js v18.17.1.
Type ".help" for more information.
> require('@aws-sdk/core').parseJsonBody
[Function: parseJsonBody]
alexnatea commented 1 month ago

I can see that in node_modules\@aws-sdk\client-dynamodb\dist-cjs\index.js there is a var import_core = require("@aws-sdk/core"); which points to node_modules\@aws-sdk\client-dynamodb\node_modules\@aws-sdk\core\dist-types\index.d.ts

I see that node_modules\@aws-sdk\client-dynamodb\node_modules\@aws-sdk\core\package.json says that this package describes the following:

{ "name": "@aws-sdk/core", "version": "3.496.0", "description": "Core functions & classes shared by multiple AWS SDK clients", ... }

Installing @aws-sdk/core@3.576.0 to my dependencies didn't solved my problem, that var import_core = require("@aws-sdk/core"); pointing not to the new package installed in root of @aws-sdk but here: node_modules\@aws-sdk\client-dynamodb\node_modules\@aws-sdk\core\

kuhe commented 1 month ago

Nesting indicates you have inconsistent versions of SDK packages installed. If your package.json indicates consistent versions like 3.577.0 for all clients, then you should update your lockfile by deleting it and reinstalling packages.

github-actions[bot] commented 2 weeks ago

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.