fix(dynamodb): migrate to ActionResult serialization and fix timestamp/binary handling#9773
Open
yusuke-koyoshi wants to merge 5 commits intogetmoto:masterfrom
Open
fix(dynamodb): migrate to ActionResult serialization and fix timestamp/binary handling#9773yusuke-koyoshi wants to merge 5 commits intogetmoto:masterfrom
yusuke-koyoshi wants to merge 5 commits intogetmoto:masterfrom
Conversation
…rializer StreamRecord.ApproximateCreationDateTime, Table.CreationDateTime, Backup.BackupCreationDateTime, and RestoreDateTime now store raw datetime objects instead of pre-converted epoch/isoformat values, letting the ActionResult serializer handle the conversion. Added dynamo_to_dict() to recursively convert DynamoDB model objects (DynamoType, to_json objects) to plain dicts while preserving datetime for ActionResult and decoding B/BS to raw bytes to avoid double base64 encoding. Updated DynamoJsonEncoder to handle datetime natively (for SizeBytes calculation) and reordered type checks so datetime is checked before to_json in both DynamoJsonEncoder and dynamo_to_dict for consistency.
Replace dynamo_json_dump()/json.dumps() with ActionResult() across all 38 handler methods in responses.py, letting the core serializer handle JSON encoding and timestamp formatting. Refactored include_consumed_capacity decorator to work with ActionResult directly and use MockValidationException instead of manual HTTP tuple construction. Fixed ReturnValues=NONE behavior for put_item, delete_item, and update_item to not include an Attributes key, matching AWS behavior. Added explicit ALL_NEW handling in update_item.
Fixed send_dynamodb_items in awslambda to call item.to_json() once instead of 5 times, and explicitly convert datetime to epoch at the Lambda event payload boundary. Added test_binary_attr_put_delete_update_return_values covering B/BS types through put_item, delete_item, and update_item with various ReturnValues options. Updated existing tests: freeze_time for SizeBytes stability, ReturnValues=NONE assertions to expect no Attributes key.
The long line in dynamo_to_dict was failing the ruff format --check in the CI lint job. Split it into multiple lines to comply with the formatting rules.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9773 +/- ##
==========================================
- Coverage 93.11% 93.11% -0.01%
==========================================
Files 1308 1308
Lines 118845 118872 +27
==========================================
+ Hits 110665 110686 +21
- Misses 8180 8186 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates all DynamoDB responses from dynamo_json_dump() / json.dumps() to ActionResult serialization, fixing timestamp and binary value handling.
Changes
Timestamp handling improvements
Unified response serialization
New dynamo_to_dict() helper
Behavior fixes
Tests