-
Notifications
You must be signed in to change notification settings - Fork 79
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
Conversation
There was a problem hiding this 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.
.../main/kotlin/software/amazon/smithy/aws/swift/codegen/customization/s3/S3ErrorIntegration.kt
Show resolved
Hide resolved
LGTM, could you add documentation for public APIs? |
var requestId: String? { | ||
return headers.value(for: "x-amz-request-id") | ||
} | ||
|
||
var requestId2: String? { | ||
return headers.value(for: "x-amz-id-2") | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
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 definesisEmpty
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 expectingRequestId
. 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 bothRequestID
andRequestId
.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
withRequestID
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.