aws / aws-sdk-js-v3

Modularized AWS SDK for JavaScript.
Apache License 2.0
3.09k stars 576 forks source link

Enable calling commands without passing a value #424

Closed Doug-AWS closed 3 months ago

Doug-AWS commented 4 years ago

Is your feature request related to a problem? Please describe.

I tried:

const DDB = require('@aws-sdk/client-dynamodb-node')
const dbClient = new DDB.DynamoDBClient({ region: 'us-west-2' })

dbClient
  .send(new DDB.ListTablesCommand())
  .then(response => {
    console.log(response.TableNames.join('\n'))
  })
  .catch(error => {
    console.error(error)
  })

But got the error:

Error: Unable to serialize value of type undefined as a structure
    at JsonBuilder.format (D:\JavaScriptSDKV3\node_modules\@aws-sdk\json-builder\build\index.js:22:23)
    at JsonBuilder.build (D:\JavaScriptSDKV3\node_modules\@aws-sdk\json-builder\build\index.js:14:36)
    at JsonRpcSerializer.serialize (D:\JavaScriptSDKV3\node_modules\@aws-sdk\protocol-json-rpc\build\JsonRpcSerializer.js:14:42)
    at Object.<anonymous> (D:\JavaScriptSDKV3\node_modules\@aws-sdk\middleware-serializer\build\index.js:15:53)
    at step (D:\JavaScriptSDKV3\node_modules\tslib\tslib.js:136:27)
    at Object.next (D:\JavaScriptSDKV3\node_modules\tslib\tslib.js:117:57)
    at fulfilled (D:\JavaScriptSDKV3\node_modules\tslib\tslib.js:107:62)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)

Which went away when I changed the call to ListTableCommand to (note the braces):

 .send(new DDB.ListTablesCommand({}))

Describe the solution you'd like

I'd like to see it work without the empty braces.

Describe alternatives you've considered

Otherwise, I'll have to document this and will worry about discoverability.

Additional context

None.

github-actions[bot] commented 3 years ago

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

vvo commented 2 years ago

Just want to mention how confusing this issue is whenever I use the v3 client: I spent 10 minutes trying to see if there was any required parameter and ended up deciding to pass an empty object which looks very weird.

Thanks.

aBurmeseDev commented 4 months ago

Hi @Doug-AWS @vvo - thanks for your patience.

This feature was implemented a few months ago with PR that address the issue. Please let us know if you have any other feedbacks or questions!

github-actions[bot] commented 3 months 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.