boto/boto3

EC2.Client.describe_volumes does not document surprising behavior of VolumeIds param when passed as []

kac460 opened this issue · 4 comments

Describe the issue

The VolumeIds param of describe_volumes has some surprising behavior: if you pass an empty list [] then all volume ids are matched. It's easy to see how this surprising behavior is potentially problematic if someone does not realize this is the behavior. But this behavior is not documented in the boto3 docs; the description is only:

The volume IDs.

The docs should explain this behavior.

Links

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/describe_volumes.html

Hi @kac460, thanks for reaching out. I was able to reproduce this behavior, but I'm not sure I agree with it being surprising. The SDK interprets the empty list as if the parameter wasn't included at all. What were you anticipating the behavior to be?

Hi @kac460, thanks for reaching out. I was able to reproduce this behavior, but I'm not sure I agree with it being surprising. The SDK interprets the empty list as if the parameter wasn't included at all. What were you anticipating the behavior to be?

Thanks for the reply. I'd expect either nothing to match or for an error to be raised. It's dangerous if you have, for example, a script that

  1. Finds/generates a list of volume ids based on some criteria
  2. Passes that list to describe_volumes
  3. Does some action for every volume returned by describe_volumes

This script would be unsafe if the criteria for (1) match no volume ids resulting in an empty list. Then the output for (3) will include every single volume in the account, so the action which shouldn't be taken on any volume (since none matched the criteria in (1)) would in actuality be taken on all volumes.

Gotcha. I've reached out to the EC2 team about this documentation clarification. As this is a service team issue, I've created a tracking issue in our cross-SDK repository (aws/aws-sdk#755). Please refer to that issue for updates going forward. Thanks!

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.