aws / aws-sdk-js-v3

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

`DescribeSnapshotsCommand` mishandles empty array of filters #6063

Closed wuhkuh closed 1 month ago

wuhkuh commented 2 months ago

Checkboxes for prior research

Describe the bug

When I configure an empty array of filters for DescribeSnapshotsCommand, I get the response InvalidParameterValue: The filter 'null' is invalid from the backend.

SDK version number

@aws-sdk/client-ec2@3.569.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v20.12.2

Reproduction Steps

import { DescribeSnapshotsCommand, EC2Client } from "@aws-sdk/client-ec2";

const client = new EC2Client();
const describeResponse = await client.send(
  new DescribeSnapshotsCommand({
    Filters: []
  })
);

console.log(describeResponse);

Observed Behavior

I got the following response:

const response = new exceptionCtor({
                 ^

InvalidParameterValue: The filter 'null' is invalid
  at throwDefaultError$4
  at de_CommandError$3
  <truncated for brevity, the remainder is mangled>

  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '8a591f88-4042-40c4-9ab2-974fcc3c4aa9',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  Code: 'InvalidParameterValue'
}

Expected Behavior

No filters should be applied, when the array of filters to be applied is empty. I expected to receive all snapshots (an unfiltered response) for the request.

Possible Solution

Additional Information/Context

No response

aBurmeseDev commented 1 month ago

Hi @wuhkuh - thanks for reaching out.

No filters should be applied, when the array of filters to be applied is empty. I expected to receive all snapshots (an unfiltered response) for the request.

That's current behavior that it returns unfiltered response without param Filters and that’s the same behavior for across SDKs. Can you help me understand your specific use case that you'd like to keep Filters param with empty array there?

This code example will return all snapshots (unfiltered)

import { EC2Client, DescribeSnapshotsCommand } from "@aws-sdk/client-ec2"; // ES Modules import
const client = new EC2Client({
    region: "us-west-1"
});
const command = new DescribeSnapshotsCommand({});
const response = await client.send(command);

Hope it helps, John

syall commented 1 month ago

@wuhkuh - For more context, did you encounter this issue when updating the SDK dependency version, or is this new code?

github-actions[bot] commented 1 month ago

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

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