Skip to content
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

fix: Fixes S3 and Ec2 error parsing #787

Merged
merged 8 commits into from
Jan 5, 2023
Merged

fix: Fixes S3 and Ec2 error parsing #787

merged 8 commits into from
Jan 5, 2023

Conversation

epau
Copy link
Contributor

@epau epau commented Dec 28, 2022

This PR fixes issues with parsing S3 and Ec2 errors.

S3 errors were failing to parse correctly when the error was a 404 with an empty body. The cause of this issue is that our local logic to check if the body is empty was incorrect. It previously, defined isEmpty as having a httpBody instance that equaled .data(nil). Now, it defines isEmpty as having a httpBody instance that is either .none, or the data is nil or is empty.

Ec2 errors were failing to parse correctly because the request id key in the response is RequestID while we were expecting RequestId. According to the smithy spec for Ec2Query protocol, RequestId is correct so this appears to a special case for the Ec2 service. Now the Ec2 error models will attempt to parse using both RequestID and RequestId.

After this issue is done, we can come back here and fix the Ec2 errors in a different way. We can define a custom key decoding strategy, and always replace the key RequestId with RequestID just for the Ec2 client.

Issue #

#761
#759

Description of changes

New/existing dependencies impact assessment, if applicable

Conventional Commits

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@epau epau marked this pull request as ready for review December 28, 2022 16:26
Copy link
Contributor

@jbelkins jbelkins left a comment

Choose a reason for hiding this comment

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

Overall good, just a couple Q's.

Good that we are moving logic out of generated code along with fixing these bugs.

@ganeshnj
Copy link
Contributor

LGTM, could you add documentation for public APIs?

Comment on lines 14 to 20
var requestId: String? {
return headers.value(for: "x-amz-request-id")
}

var requestId2: String? {
return headers.value(for: "x-amz-id-2")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this extension should be headers collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, and can go either way here. IMO the fact that these values come from headers are implementation details. That being said, it could be cool to live in a world where all the headers are defined on Headers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense.

@epau epau requested review from jbelkins and ganeshnj January 5, 2023 15:35
@epau epau merged commit 40e66dd into main Jan 5, 2023
@epau epau deleted the epau/fix/error-parsing branch January 5, 2023 21:08
@epau epau mentioned this pull request Feb 22, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants