aws / aws-sdk-java-v2

The official AWS SDK for Java - Version 2
Apache License 2.0
2.16k stars 836 forks source link

InternetGatewayAttachment state and stateAsString mismatch #5395

Closed nmesika-te closed 2 months ago

nmesika-te commented 2 months ago

Describe the bug

When calling describeInternetGateways and iterating over the attachments, the method stateAsString returns available while the corresponding state() method returns UNKNOWN_TO_SDK (should presumably return a specific enum value AVAILABLE).

These values are defined in AttachmentStatus class

Expected Behavior

return an enum value AVAILABLE.

Current Behavior

returns enum UNKNOWN_TO_SDK

Reproduction Steps

        try (var client = Ec2Client.builder().build()) {
            var igResp = client.describeInternetGateways(DescribeInternetGatewaysRequest.builder().build());

            for (var igw : igResp.internetGateways()) {
                for (var att : igw.attachments()) {
                    if (att.stateAsString().equalsIgnoreCase("available")) {
                        System.out.println("string=" + att.stateAsString());
                        System.out.println("enum=" + att.state());
                    }
                }
            }
        }

prints

string=available
enum=null

Possible Solution

In services/ec2/src/main/resources/codegen-resources/service-2.json:8940 add another value available.

Additional Information/Context

The API XML DescribeInternetGatewaysResponse looks like the following (note the "available" value)

        <item>
            <internetGatewayId>igw-0ad14a26af5152f82</internetGatewayId>
            <ownerId>036476006320</ownerId>
            <attachmentSet>
                <item>
                    <vpcId>vpc-04f987fff6675ec10</vpcId>
                    <state>available</state>
                </item>
            </attachmentSet>

AWS Java SDK version used

2.26.18

JDK version used

openjdk version "17.0.9" 2023-10-17

Operating System and version

Linux 5.10.219-208.866.amzn2.x86_64 #1 SMP Tue Jun 18 14:00:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

bhoradc commented 2 months ago

Hi @nmesika-te,

These enumerations are generated from service model shared by EC2 service team. This issue has been reported earlier in GO SDK (https://github.com/aws/aws-sdk/issues/586) and has been tracked in this Shared SDK repo.

EC2 service team is aware of this issue and has been investigating it. I will therefore go ahead and mark this as closing-soon. You may track the above mentioned Shared SDK issue. Kindly let me know if you have further queries.

Regards, Chaitanya

nmesika-te commented 2 months ago

Thanks! Although given that the go-sdk issue was created on Aug 23, I guess AWS considers its SDKs "good enough" and are reluctant to make changes.