aws / aws-sdk

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

The Wellarchitected GetConsolidatedReport API throwes error when we are passing the `Format` as `JSON` in the input parameter #523

Closed ParthaI closed 1 year ago

ParthaI commented 1 year ago

Describe the bug

The API GetConsolidatedReport throws the following error when we are passing the Format value as JSON in the input param.

Input:

    input := &wellarchitected.GetConsolidatedReportInput{
        Format:                 types.ReportFormatJson,
        IncludeSharedResources: true,
        MaxResults:             int32(15),
    }

Error:

Error: operation error WellArchitected: GetConsolidatedReport, https response error StatusCode: 200, RequestID: 6381396e-e959-4678-a352-221a60e99dc9, deserialization failed, failed to decode response body with invalid JSON, expected LensesAppliedCount to be json.Number, got string instead

I was having a look at the AWS API doc, here it is mentioned that the datatype of the property LensesAppliedCount is an integer.

In the Go SDK the property LensesAppliedCount is also an integer type.

But while I am running the AWS CLI command(aws wellarchitected get-consolidated-report --format JSON) I am getting the value as a string. Screenshot 2023-04-13 at 6 21 53 PM

Expected Behavior

The API GetConsolidatedReport should not throw any error.

Current Behavior

The API GetConsolidatedReport throws an error deserialization failed, failed to decode response body with invalid JSON, expected LensesAppliedCount to be json.Number, got string instead while typecasting a JSON value to integer type

Reproduction Steps

package main

import (
    "context"
    "fmt"
    "log"

    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"

    "github.com/aws/aws-sdk-go-v2/service/wellarchitected"
)

func main() {
    listConsolidateReports("us-east-1")
}

func listConsolidateReports(region string) {
    fmt.Println("Region:", region)
    ctx := context.Background()
    configOptions := []func(*config.LoadOptions) error{
        config.WithRegion(region),
    }

    cfg, err := config.LoadDefaultConfig(ctx, configOptions...)
    if err != nil {
        log.Fatalln("load_default_config", err)
    }

    svc := wellarchitected.NewFromConfig(cfg)

    input := &wellarchitected.GetConsolidatedReportInput{
        Format:                 types.ReportFormatJson,
        IncludeSharedResources: true,
        MaxResults:             maxLimit,
    }

    paginator := wellarchitected.NewGetConsolidatedReportPaginator(svc, input, func(o *wellarchitected.GetConsolidatedReportPaginatorOptions) {
        o.Limit = maxLimit
        o.StopOnDuplicateToken = true
    })

    // List call
    for paginator.HasMorePages() {
        output, err := paginator.NextPage(ctx)
        if err != nil {
            log.Fatalln("pagging error", err)
            return nil, err
        }

        for _, items := range output.Metrics {
            fmt.Println("Result :", item)
        }

    }

}

Possible Solution

We need to update the datatype of the property LensesAppliedCount to string.

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2 v1.17.8 github.com/aws/aws-sdk-go-v2/service/wellarchitected v1.19.2

Compiler and Version used

go version go1.19.2 darwin/arm64

Operating System and version

MacOS Big Sur - Version 11.4

RanVaknin commented 1 year ago

Hi @ParthaI ,

Thanks for opening the issue. Unfortunately the SDK team cannot change the data types of the SDK, they are auto-generated from the API model that the Well Architected Service published.

I have create an internal ticket with the Well Architected service team and I will update you when we have any news from them.

Thanks, Ran

P86430644

RanVaknin commented 1 year ago

Hi @ParthaI

This is now fixed.

Thanks again. Ran~

github-actions[bot] commented 1 year ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.