aws / aws-sdk-go-v2

AWS SDK for the Go programming language.
https://aws.github.io/aws-sdk-go-v2/docs/
Apache License 2.0
2.61k stars 627 forks source link

DescribeVpcEndpoints returns the State value in lowercase instead of UpperCamelCase #2785

Closed rajramo61 closed 2 weeks ago

rajramo61 commented 2 weeks ago

Acknowledgements

Describe the bug

Issue: When we make call to DescribeVpcEndpoints it returns this State field with value in all characters lower case (available) contrary to what the client State constant defines first character in upper case(Available).

Regression Issue

Expected Behavior

I expect DescribeVpcEndpoints returns the State field with enum using the same casing as defined in the State. For example the string value for State should be like Failed and not like failed .

Current Behavior

DescribeVpcEndpoints returns the State field string value in all lower case like failed.

Reproduction Steps

Here is the sample code to reproduce the issue. Replace with real vpcEndpointId . if the result says Expected Success then there is no issue and if it returns Manipulated Success then this bug exists.

package main

import (
    "context"
    "fmt"
    "log"
    "strings"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/ec2"
    "github.com/aws/aws-sdk-go-v2/service/ec2/types"
)

func main() {
    ctx := context.TODO()
    cfg, err := config.LoadDefaultConfig(ctx)
    if err != nil {
        log.Fatal(err)
    }
    client := ec2.NewFromConfig(cfg)
    input := &ec2.DescribeVpcEndpointsInput{
        VpcEndpointIds: []string{"<vpc-endpoint-id>"},
    }
    vpcEndpointsOutput, err := client.DescribeVpcEndpoints(ctx, input)
    if err != nil {
        fmt.Println("failed", err)
    }
    state := vpcEndpointsOutput.VpcEndpoints[0].State
    fmt.Println(state)
    states := types.StatePending.Values()
    for _, s := range states {
        if strings.ToLower(string(s)) == strings.ToLower(string(state)) {
            fmt.Println("checking the correct value")
            fmt.Println(s)
            if s == types.StateAvailable {
                fmt.Println("Manipulated Success")
            }
        }
    }
    if state == types.StateAvailable {
        fmt.Println("Expected Success")
    }
}

Possible Solution

Not sure if this issue is related to deserialization of issue at the server and client values for State.

Additional Information/Context

NA

AWS Go SDK V2 Module Versions Used

This list is too big. The ticket creation failed so I omitted the information, I can provide the details in the comment later.

Compiler and Version used

go version go1.23.0 darwin/amd64

Operating System and version

macOS Sonoma Version 14.6.1

bhavya2109sharma commented 2 weeks ago

Hello @rajramo61

Thanks for reaching out.

I have reproduced and confirmed that this is an issue. This was also reported in the past and not yet fixed by the EC2 service team https://github.com/aws/aws-sdk/issues/116 , and I am tracking internal ticket (#70319347). I will reach out to the service team once again to try and get them to fix it.

I'll be closing this issue in favor of tracking it in the original reported github issue

Thanks, Bhavya

github-actions[bot] commented 2 weeks ago

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.

rajdwi commented 2 weeks ago

Thanks @bhavya2109sharma for the updates! Not sure if it would be a good idea to close this ticket but I would leave it up to you. With this ticket being closed, someone else might create a new ticket for the same issue as folks mostly check the open tickets. The original ticket is open with older version of sdk which most of the folks won't check.