Skip to content
New issue

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

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

Already on GitHub? # to your account

Use request body error message for unknown errors missing a message header #4740

Merged
merged 3 commits into from
Mar 15, 2023
Merged

Use request body error message for unknown errors missing a message header #4740

merged 3 commits into from
Mar 15, 2023

Conversation

jar-b
Copy link
Contributor

@jar-b jar-b commented Feb 27, 2023

Closes #4733

This fix will handle cases when an unknown error response includes a code header, but not a message header. Rather than returning an empty message (the current behavior) the message parsed from the JSON body is returned.

Here is a trivial example of a lambda ValidationException before and after the change:

Before:

ValidationException:
        status code: 400, request id: 455ba702-2c14-42e4-993f-f091b2e956e2

After:

ValidationException: 1 validation error detected: Value '2000' at 'timeout' failed to satisfy constraint: Member must have value less than or equal to 900
        status code: 400, request id: 60e3a922-3eec-4fb3-b3fe-83c8e2bca1ed

Also adds a pair of unit tests to cover "unknown" response cases with partial headers (ie. code without message and vice-versa):

$ go test -count=1 ./private/protocol/restjson/...
ok      github.com/aws/aws-sdk-go/private/protocol/restjson     4.008s

Comment on lines +60 to +62
if len(code) == 0 {
code = jsonErr.Code
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition was added to preserve backward compatibility and prevent the code from being overwritten if the code header was present.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, this is also in line with both the smithy docs on restjson error type as well as a change we recently made in this area in go v2.

@jar-b
Copy link
Contributor Author

jar-b commented Mar 2, 2023

@lucix-aws - Thanks for the review! Is there anything else required for this to be merged?

@lucix-aws
Copy link
Contributor

@jar-b Sorry for the delayed response - I'm picking this back up this week. It should be good to merge after CI passes.

@lucix-aws lucix-aws merged commit 25c011f into aws:main Mar 15, 2023
@jar-b jar-b deleted the fix-unknown-code-header-only branch March 15, 2023 18:55
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ValidationException missing message on Lambda function creation
2 participants