Skip to content

fix(dynamodb): add test for put_item with ReturnValues='ALL_OLD' on new items#9778

Open
thakoreh wants to merge 1 commit intogetmoto:masterfrom
thakoreh:fix/dynamodb-putitem-returnvalues
Open

fix(dynamodb): add test for put_item with ReturnValues='ALL_OLD' on new items#9778
thakoreh wants to merge 1 commit intogetmoto:masterfrom
thakoreh:fix/dynamodb-putitem-returnvalues

Conversation

@thakoreh
Copy link

Summary

Related to #9757

Adds a test case verifying that put_item() with ReturnValues='ALL_OLD' returns an empty Attributes map when creating a new item (not replacing an existing one).

Behavior

Per AWS DynamoDB documentation:

  • ReturnValues='ALL_OLD' returns the old item attributes if an item was replaced
  • For new items (no existing item to replace), returns {"Attributes": {}}

Test Added

test_put_item_return_values_all_old_new_item - verifies the empty Attributes response for new items.

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.11%. Comparing base (c233a61) to head (fc958ce).
⚠️ Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9778   +/-   ##
=======================================
  Coverage   93.11%   93.11%           
=======================================
  Files        1308     1308           
  Lines      118798   118798           
=======================================
+ Hits       110615   110617    +2     
+ Misses       8183     8181    -2     
Flag Coverage Δ
servertests 28.89% <ø> (ø)
unittests 93.08% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.


# Test 3: Put a NEW item with ReturnValues='ALL_OLD' - should return empty Attributes map
# This is the correct AWS behavior: when putting a new item that doesn't exist,
# ReturnValues='ALL_OLD' should return {"Attributes": {}} not omit the key
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't this comment contradict #9757, which says "in the case of a new entry, DynamoDB itself doesn't include an Attributes attribute in the response"? You are saying here that the key should not be omitted--were you able to verify that against a real AWS backend?

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.

2 participants