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.63k stars 634 forks source link

Backup Vault `GetBackupVaultNotifications` always return error #1885

Closed ParthaI closed 2 years ago

ParthaI commented 2 years ago

Describe the bug

While making the GetBackupVaultNotifications API call with AWS SDK V1, instead of throwing an error it returns a null value if no event notification is available but the AWS SDK V2 throwing an error (Error: operation error Backup: GetBackupVaultNotifications, https response error StatusCode: 400, RequestID: ffb8c91d-b86c-426b-ad2b-3c495a4e3da0, api error ERROR_2106: Failed reading notifications from database for Backup vault aws/efs/automatic-backup-vault) instead of returning null value.

Expected Behavior

The API should not return an error if there is no event notification available for a backup vault.

Current Behavior

The API always throws an error if no data is available.

Reproduction Steps

package main

import (
    "context"
    "log"
        "fmt"
    "github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/backup"
    "github.com/aws/aws-sdk-go-v2/service/backup"
)

func main() {
    // Load the Shared AWS Configuration (~/.aws/config)
    cfg, err := config.LoadDefaultConfig(context.TODO())
    if err != nil {
        log.Fatal(err)
    }

    // Create an Amazon Backup service client
    client := backup.NewFromConfig(cfg)

    params := &backup.GetBackupVaultNotificationsInput{
        BackupVaultName: aws.String(<Backup Vault Name>),
    }

        op, err := svc.GetBackupVaultNotifications(ctx, params)
       if err != nil {
      fmt.Errorf("Error: %v", err)
    }
    fmt. Println(op)
}

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

module github.com/lalit/steampipe-plugin-aws

go 1.19

require (
    github.com/aws/aws-sdk-go v1.44.49
    github.com/aws/aws-sdk-go-v2 v1.16.16
    github.com/aws/aws-sdk-go-v2/config v1.17.8
    github.com/aws/aws-sdk-go-v2/credentials v1.12.21
    github.com/aws/aws-sdk-go-v2/service/accessanalyzer v1.16.0
    github.com/aws/aws-sdk-go-v2/service/account v1.7.8
    github.com/aws/aws-sdk-go-v2/service/acm v1.14.8
    github.com/aws/aws-sdk-go-v2/service/apigateway v1.15.10
    github.com/aws/aws-sdk-go-v2/service/apigatewayv2 v1.12.8
    github.com/aws/aws-sdk-go-v2/service/appconfig v1.13.7
    github.com/aws/aws-sdk-go-v2/service/auditmanager v1.20.4
    github.com/aws/aws-sdk-go-v2/service/autoscaling v1.23.10
    github.com/aws/aws-sdk-go-v2/service/backup v1.17.5
    github.com/aws/aws-sdk-go-v2/service/cloudcontrol v1.10.13
    github.com/aws/aws-sdk-go-v2/service/cloudformation v1.22.10
    github.com/aws/aws-sdk-go-v2/service/cloudfront v1.20.0
    github.com/aws/aws-sdk-go-v2/service/cloudtrail v1.16.8
    github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.21.6
    github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs v1.15.14
    github.com/aws/aws-sdk-go-v2/service/codeartifact v1.13.6
    github.com/aws/aws-sdk-go-v2/service/codebuild v1.19.13
    github.com/aws/aws-sdk-go-v2/service/codedeploy v1.14.16
    github.com/aws/aws-sdk-go-v2/service/codepipeline v1.13.15
    github.com/aws/aws-sdk-go-v2/service/configservice v1.26.1
    github.com/aws/aws-sdk-go-v2/service/costexplorer v1.19.2
    github.com/aws/aws-sdk-go-v2/service/databasemigrationservice v1.21.10
    github.com/aws/aws-sdk-go-v2/service/dax v1.11.15
    github.com/aws/aws-sdk-go-v2/service/directoryservice v1.14.11
    github.com/aws/aws-sdk-go-v2/service/dlm v1.12.4
    github.com/aws/aws-sdk-go-v2/service/docdb v1.19.11
    github.com/aws/aws-sdk-go-v2/service/dynamodb v1.15.9
    github.com/aws/aws-sdk-go-v2/service/ec2 v1.52.1
    github.com/aws/aws-sdk-go-v2/service/ecr v1.17.16
    github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.13.15
    github.com/aws/aws-sdk-go-v2/service/ecs v1.18.19
    github.com/aws/aws-sdk-go-v2/service/efs v1.17.15
    github.com/aws/aws-sdk-go-v2/service/elasticache v1.22.10
    github.com/aws/aws-sdk-go-v2/service/elasticbeanstalk v1.14.18
    github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing v1.14.12
    github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.18.12
    github.com/aws/aws-sdk-go-v2/service/elasticsearchservice v1.16.10
    github.com/aws/aws-sdk-go-v2/service/eventbridge v1.16.15
    github.com/aws/aws-sdk-go-v2/service/fsx v1.24.14
    github.com/aws/aws-sdk-go-v2/service/glue v1.32.0
    github.com/aws/aws-sdk-go-v2/service/guardduty v1.15.9
    github.com/aws/aws-sdk-go-v2/service/iam v1.18.9
    github.com/aws/aws-sdk-go-v2/service/identitystore v1.15.5
    github.com/aws/aws-sdk-go-v2/service/inspector v1.12.15
    github.com/aws/aws-sdk-go-v2/service/kafka v1.17.15
    github.com/aws/aws-sdk-go-v2/service/kms v1.18.11
    github.com/aws/aws-sdk-go-v2/service/lambda v1.24.6
    github.com/aws/aws-sdk-go-v2/service/organizations v1.16.8
    github.com/aws/aws-sdk-go-v2/service/pricing v1.16.8
    github.com/aws/aws-sdk-go-v2/service/ram v1.16.18
    github.com/aws/aws-sdk-go-v2/service/rds v1.26.1
    github.com/aws/aws-sdk-go-v2/service/redshift v1.26.10
    github.com/aws/aws-sdk-go-v2/service/redshiftserverless v1.2.9
    github.com/aws/aws-sdk-go-v2/service/route53 v1.22.2
    github.com/aws/aws-sdk-go-v2/service/route53domains v1.12.17
    github.com/aws/aws-sdk-go-v2/service/route53resolver v1.15.19
    github.com/aws/aws-sdk-go-v2/service/s3 v1.27.1
    github.com/aws/aws-sdk-go-v2/service/s3control v1.21.9
    github.com/aws/aws-sdk-go-v2/service/sagemaker v1.46.0
    github.com/aws/aws-sdk-go-v2/service/securityhub v1.23.5
    github.com/aws/aws-sdk-go-v2/service/sns v1.17.9
    github.com/aws/aws-sdk-go-v2/service/sqs v1.19.10
    github.com/aws/aws-sdk-go-v2/service/ssm v1.30.0
    github.com/aws/aws-sdk-go-v2/service/waf v1.11.17
    github.com/aws/aws-sdk-go-v2/service/wafregional v1.12.18
    github.com/aws/aws-sdk-go-v2/service/wafv2 v1.22.9
    github.com/aws/smithy-go v1.13.3
    github.com/gocarina/gocsv v0.0.0-20201208093247-67c824bc04d4
    github.com/golang/protobuf v1.5.2
    github.com/turbot/go-kit v0.4.0
    github.com/turbot/steampipe-plugin-sdk/v4 v4.1.7
    golang.org/x/text v0.3.7
)

Compiler and Version used

go version go1.19.2 darwin/arm64

Operating System and version

MacOS Big Sur - Version 11.4

RanVaknin commented 2 years ago

Hi @ParthaI ,

Thanks for opening this thread and engaging in the community!

After looking into this in depth I came up with these 2 conclusions:

  1. the backup service API does not offer a flattering response when making a request to a backup vault with 0 events in it. Ideally it should return an empty array.

  2. The V1 SDK simply returns an empty &backup.GetBackupVaultNotificationsOutput{} object and ignores the exception given from the server. This is why you are seeing a more flattering response in V1, but the truth is that the SDK should in fact raise an exception. If you enable wire logs on V1 you'll see the following response:

---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Content-Length: 137
Content-Type: application/json
Date: Fri, 14 Oct 2022 15:20:45 GMT
X-Amzn-Errortype: ResourceNotFoundException:http://internal.amazon.com/coral/com.amazonaws.services.cryo/
X-Amzn-Requestid: <redacted>

-----------------------------------------------------
2022/10/14 08:20:45 {"Code":"ERROR_2106","Context":"testVault","Message":"Failed reading notifications from database for Backup vault testVault","Type":null}
{

}

I have reached out to the backup service team with a feature request to try and return a more sensible response in the form of an empty array. Since the V2 SDK is behaving as expected so there is no action item for us here.

If you have any additional questions please let me know. Thanks again! Ran~

github-actions[bot] commented 2 years ago

This issue has not received a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

ParthaI commented 2 years ago

Hi @RanVaknin, Thanks for your update, Is there an ETA when the feature request will get released?

RanVaknin commented 2 years ago

Hi @ParthaI ,

I just heard back from the manager of that team. The feature request was already raised twice before with that team but it seems like they cannot provide a timeline (and even if they could, we are forbidden from disclosing such information publicly)

In the spirit of transparency I'll say that these things are very very slow, and can take months to get addressed with internal teams.

Since there is no action here from the SDK team, and I did get a "will implement, but without timeline" from the service team I will go ahead and close this issue.

To unblock on v2, you can simply do something like the following:

    op, err := client.GetBackupVaultNotifications(context.Background(), params)
    if err != nil {
        if strings.Contains(err.Error(), " Failed reading notifications from database for Backup vault ") {
            op = &backup.GetBackupVaultNotificationsOutput{}
        }
    }

I'll suggest checking the releases every couple of weeks to see if this has been implemented.

Thanks again~ Ran

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

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.