-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ASF: fix exception serialization for smithy-rpc-v2-cbor and json protocol
#13180
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
Conversation
be37fe7 to
778c673
Compare
778c673 to
bb7ab45
Compare
LocalStack Community integration with Pro 2 files ±0 2 suites ±0 1h 58m 29s ⏱️ +23s Results for commit d4642d1. ± Comparison against base commit 4be950c. This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
bb7ab45 to
cc64c6a
Compare
Test Results - Alternative Providers459 tests - 781 287 ✅ - 414 7m 37s ⏱️ - 33m 10s Results for commit d4642d1. ± Comparison against base commit 4be950c. This pull request removes 790 and adds 9 tests. Note that renamed tests count towards both.This pull request removes 375 skipped tests and adds 8 skipped tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Test Results (amd64) - Integration, Bootstrap 5 files ±0 5 suites ±0 2h 34m 51s ⏱️ - 1m 14s Results for commit d4642d1. ± Comparison against base commit 4be950c. This pull request removes 2 and adds 9 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
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.
Wow, that's quite a deep dive! 🤿 🤩
With the changes here and the strong similarities between the CBOR and JSON serializers, I am really wondering if we are missing an abstraction level which could simplify the two serializers and their weird special behavior in combination with the query protocol and the shape handling. Specifically also when looking at the changes in the _serialize_error method in the two serializers. What do you think?
…l Mixin, rework the `__type` hack to do a shallow copy
alexrashed
left a comment
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.
Awesome! Thanks for addressing the comments! The default response serializer are minimal now, and the weird query handling is nicely encapsulated in the mixin! 💯
| value: dict, | ||
| shape: Shape | None, | ||
| name: str | None = None, | ||
| shape_members: dict[str, Shape] | None = None, |
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.
nit: It think it would be good to mention why the signature of this _serialize_type_structure differs from all the others (as it's also used for the specific error serialization).
Motivation
This PR is part of a bigger initiative (see #13028) to implement support for the new Smithy Protocol
smithy-rpc-v2-cbor, as well as the new Botocore multi-protocol support for single services (before, a service could only define one protocol)This PR fixes the ASF / CloudWatch issues encountered during validating the full test suite (see #13173). Those were cherry picked to make the PR more digestible and understand which tests needed the fix.
A failure popped up when the exception message would be empty for the
jsonandsmithy-rpc-v2-cbor: themessagefield would not be serialized at all when the value would be empty. I validated that it's actually the behavior wanted as I knew the KMS serviced the same thing, and realized it had snapshot skips so fixed it for everything.I've also found a major issue: the CBOR serializer absolutely needs a Botocore
Shapein order to serialize any structure, but our custom-defined exception subclassed fromCommonServiceExceptionwon't have any. I created a workaround by defining a fallback shape in case it is not defined, with the default field the serializer needs to properly encode the error.This is also used by the
jsonserializer, as it was doing some workaround by manually setting some keys in the dictionary.I've also realized that the CloudWatch service will return different status code for exceptions, depending on the protocol and the
x-amzn-query-moderequest header, so this behavior has been implemented.There is also a small fix for the boolean parsing in CBOR, showed by the
test_set_alarmtest.Changes
QueryCompatibleProtocolMixinto add the utilities shared byjsonandsmithy-rpc-v2-cborto clean up__typehack to use shallow copy instead of deep copy of shape membersjsonandsmithy-rpc-v2-cborserializer for exceptions