aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 13 forks source link

OpenSearch's describe-domains action without domain names does not return info about all domains #555

Open nekketsuuu opened 1 year ago

nekketsuuu commented 1 year ago

Describe the bug

Documentation of describe-domains of OpenSearch Service says:

If you don’t specify any domains, OpenSearch Service returns information about all domains owned by the account.

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/opensearch/describe-domains.html

But it doesn't. It returns the empty array if I set domains to the empty.

Expected Behavior

% aws opensearch describe-domains --domain-names
{
    "DomainStatusList": [
        ...Info of all domains here...
    ]
}

Current Behavior

% aws opensearch describe-domains --domain-names
{
    "DomainStatusList": []
}

Reproduction Steps

Just call aws opensearch describe-domains with --domain-names empty.

Possible Solution

(none)

Additional Information/Context

I also tried the same thing using AWS SDK for Ruby, but it returns the empty array, too. It may be a bug of AWS REST API, or a documentation bug of the API.

% irb
irb(main):001:0> require 'aws-sdk-opensearchservice'
=> true
irb(main):002:0> client = Aws::OpenSearchService::Client.new
=> #<Aws::OpenSearchService::Client>
irb(main):003:0> client.describe_domains({domain_names: []})
=> #<struct Aws::OpenSearchService::Types::DescribeDomainsResponse domain_status_list=[]>

Also, if you pass the empty string to --domain-names on AWS CLI, it raises an error:

% aws opensearch describe-domains --domain-names ''

Parameter validation failed:
Invalid length for parameter DomainNames[0], value: 0, valid min length: 3

CLI version used

aws-cli/2.12.1 Python/3.11.4 Darwin/22.5.0 source/arm64 prompt/off

Environment details (OS name and version, etc.)

macOS Ventura 13.4, Apple M2 Mac, MacBook Pro

tim-finnigan commented 1 year ago

Thanks @nekketsuuu for reporting this issue. I could reproduce the behavior you described. This is an issue with the OpenSearch DescribeDomains API (which is used across AWS SDKs in addition to the CLI). The API documentation notes that DomainNames is a required parameter, but passing an empty list returns an empty array as you described and passing a string causes the parameter validation that you referenced.

I will transfer this issue to our cross-SDK repository and escalate this to the OpenSearch team. I'll share any updates on this issue. Thanks again for bringing this to our attention. (ref: P91858833)