Skip to content

AWS Go SDK v1.28.0 Code Generated Error Types Missing Error Message #3088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bflad opened this issue Jan 20, 2020 · 1 comment · Fixed by #3089
Closed

AWS Go SDK v1.28.0 Code Generated Error Types Missing Error Message #3088

bflad opened this issue Jan 20, 2020 · 1 comment · Fixed by #3089
Labels
bug This issue is a bug.

Comments

@bflad
Copy link
Contributor

bflad commented Jan 20, 2020

Please fill out the sections below to help us address your issue.

Version of AWS SDK for Go?

Version 1.28.5

Version of Go (go version)?

Go 1.13

What issue did you see?

Changes in v1.28.0 of the AWS Go SDK (imported and released by Terraform AWS Provider version 2.45.0) introduced code generated types for certain service error shapes, which can be used to extract additional information provided by the API response. Prior to these code generated types, most (if not all) of these errors returned the correct error messaging via Message() via the message protocol response field. However after this change, since some of these error shapes in the service API models are incorrectly missing the Message structure member, this causes the Message_ (Go struct type) to be missing, which causes the error message via Message() to always be empty.

An example of this missing error messaging can be seen with codebuild service InvalidInputException shape:

"InvalidInputException":{
"type":"structure",
"members":{
},
"exception":true
},

// Message returns the exception's message.
func (s InvalidInputException) Message() string {
return ""
}

Debug output from the application shows the error message being returned, but it does not seem possible to access given the above (note missing error message after error code and colon on last line):

2020/01/20 12:59:15 [DEBUG] [aws-sdk-go] DEBUG: Response codebuild/CreateProject Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 400 Bad Request
Connection: close
Content-Length: 167
Content-Type: application/x-amz-json-1.1
Date: Mon, 20 Jan 2020 17:59:14 GMT
X-Amzn-Requestid: 2f589026-d531-458d-b851-86bd4afb5cd0


-----------------------------------------------------
2020/01/20 12:59:15 [DEBUG] [aws-sdk-go] {"__type":"InvalidInputException","message":"CodeBuild is not authorized to perform: sts:AssumeRole on arn:aws:iam::--OMITTED--:role/tf-acc-test-4387558838057379294"}
2020/01/20 12:59:15 [DEBUG] [aws-sdk-go] DEBUG: Validate Response codebuild/CreateProject failed, attempt 0/25, error InvalidInputException:

Full SDK analysis of this new behavior was performed here: hashicorp/terraform-provider-aws#11642 (comment)

In terms of the AWS Go SDK, this change potentially affected the following services:

  • apigatewaymanagementapi
  • cloud9
  • cloudhsm
  • cloudtrail
  • cloudwatchevents
  • cloudwatchlogs
  • codebuild
  • codecommit
  • codedeploy
  • codepipeline
  • codestar
  • configservice
  • dax
  • directconnect
  • ecs
  • elasticsearchservice
  • elastictranscoder
  • emr
  • eventbridge
  • lexmodelbuildingservice
  • managedblockchain
  • pinpointemail
  • rdsdataservice
  • rekognition
  • servicecatalog
  • sesv2
  • sms
  • ssm
  • ssooidc
  • textract
  • transfer
  • waf
  • wafregional
  • workdocs

In terms of the Terraform AWS Provider, this change broke the following behaviors which were dependent on checking the previously available error messages:

Historically, we have preferred to sometimes check specific error messaging from the service API responses since the error code itself may not be descriptive enough to determine if the error could/should be retried. While the service APIs should likely introduce more granular error codes and fix their API models, the unexpected removal of the error messaging represents a fairly problematic change in the AWS Go SDK since it was previously supported by many services.

Is it possible for these errors to try and return a message, if available, even if the Message member is undefined in the API model?

References:

Steps to reproduce

From https://github.com/terraform-providers/terraform-provider-aws:

$ TF_ACC=1 go test ./aws -v -count 1 -timeout 120m -parallel 20 -run='TestAccAWSCodeBuildProject_basic'
@jasdel
Copy link
Contributor

jasdel commented Jan 20, 2020

Thanks for reporting this bug, and the in depth description of the problem. It looks like the SDK's generation needs to ensure all errors have a Message_ member regardless if the error is modeled as having the value.

We'll work on getting a fix out for this bug.

@jasdel jasdel added the bug This issue is a bug. label Jan 20, 2020
jasdel added a commit to jasdel/aws-sdk-go that referenced this issue Jan 20, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
Fixes the SDK's generated errors to all include the `Message` member
regardless if it was modeled on the error shape. This fixes the bug
identified in aws#3088 where some JSON errors were not modeled with the
Message member. This caused the errors message to be dropped, and not
retrievable.

This change also updates the SDK's generated smoke test to expect the
Message member of an error unmarshalled not to be empty.
jasdel added a commit that referenced this issue Jan 21, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Fixes the SDK's generated errors to all include the `Message` member
regardless if it was modeled on the error shape. This fixes the bug
identified in #3088 where some JSON errors were not modeled with the
Message member. This caused the errors message to be dropped, and not
retrievable.

This change also updates the SDK's generated smoke test to expect the
Message member of an error unmarshaled not to be empty.

Fixes #3088
aws-sdk-go-automation pushed a commit that referenced this issue Jan 23, 2020
===

### Service Client Updates
* `service/iam`: Updates service API and documentation
  * This release enables the Identity and Access Management policy simulator to simulate permissions boundary policies.
* `service/rds`: Updates service API, documentation, and paginators
  * This SDK release introduces APIs that automate the export of Amazon RDS snapshot data to Amazon S3. The new APIs include: StartExportTask, CancelExportTask, DescribeExportTasks. These APIs automate the extraction of data from an RDS snapshot and export it to an Amazon S3 bucket. The data is stored in a compressed, consistent, and query-able format. After the data is exported, you can query it directly using tools such as Amazon Athena or Redshift Spectrum. You can also consume the data as part of a data lake solution. If you archive the data in S3 Infrequent Access or Glacier, you can reduce long term data storage costs by applying data lifecycle policies.

### SDK Bugs
* Fix generated errors for some JSON APIs not including a message ([#3089](#3089))
  * Fixes the SDK's generated errors to all include the `Message` member regardless if it was modeled on the error shape. This fixes the bug identified in #3088 where some JSON errors were not modeled with the Message member.
aws-sdk-go-automation added a commit that referenced this issue Jan 23, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Release v1.28.8 (2020-01-23)
===

### Service Client Updates
* `service/iam`: Updates service API and documentation
  * This release enables the Identity and Access Management policy simulator to simulate permissions boundary policies.
* `service/rds`: Updates service API, documentation, and paginators
  * This SDK release introduces APIs that automate the export of Amazon RDS snapshot data to Amazon S3. The new APIs include: StartExportTask, CancelExportTask, DescribeExportTasks. These APIs automate the extraction of data from an RDS snapshot and export it to an Amazon S3 bucket. The data is stored in a compressed, consistent, and query-able format. After the data is exported, you can query it directly using tools such as Amazon Athena or Redshift Spectrum. You can also consume the data as part of a data lake solution. If you archive the data in S3 Infrequent Access or Glacier, you can reduce long term data storage costs by applying data lifecycle policies.

### SDK Bugs
* Fix generated errors for some JSON APIs not including a message ([#3089](#3089))
  * Fixes the SDK's generated errors to all include the `Message` member regardless if it was modeled on the error shape. This fixes the bug identified in #3088 where some JSON errors were not modeled with the Message member.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants