-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix CBOR timestamp parsing #11133
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 CBOR timestamp parsing #11133
Conversation
7a92481
to
d91991e
Compare
32de83f
to
c0db4c5
Compare
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, very nice and complete write up! Thanks a lot, it was very easy to understand, follow the issue and the different linked reports.
It introduces a tight coupling to the internal Python implementation, where we won't follow if anything change from the library without manually checking their code. I don't see an easy way out without forking and tracking upstream.
But as you've pointed out, the issue is so severe that, to me, this is a good trade off! It's well documented, so it should not be too hard to maintain in the future.
LGTM, maybe we can have a second pair of eyes just to be sure on the patching side 😄
c0db4c5
to
2880f8f
Compare
Motivation
Kinesis supports CBOR (Concise Binary Object Representation) encoding as
Content-Type
in addition to JSON.CBOR support was added for LocalStack with #6494 by extending our ASF parsers and serializers, and patching CBOR support into
botocore
(when being used as a proxy tokinesis-mock
).Unfortunately, AWS does not properly implement the CBOR spec when it comes to timestamp handling:
This already caused a few issues in the past, which were addressed with #6791 and #11071.
But these fixes are only working if the datetime fields are serialized as numbers instead of native timestamps.
The AWS SDK does perform a native timestamp serialization, which again leads to parsing errors (mentioned above, see reproducer linked in "Testing").
This PR addresses the CBOR timestamp parsing/serialization issues directly when using
cbor2
to en-/decode the binary data.Unfortunately, cbor2 does not easily allow patching standard en-/decoder functions, which is why the fix only works if the Python-native cbor loading code is explicitly imported from the respective private modules (happy for any input on how to make this more stable / better): agronholm/cbor2#192
Changes
cbor2
datetime encoding and decoding.cbor2
to explicitly use the Python implementation instead of the C / native library.cbor2
now).Testing
Fixes #9699