DynamoDB Streams: omit empty OldImage/NewImage from stream records#9821
Open
JackDanger wants to merge 2 commits intogetmoto:masterfrom
Open
DynamoDB Streams: omit empty OldImage/NewImage from stream records#9821JackDanger wants to merge 2 commits intogetmoto:masterfrom
JackDanger wants to merge 2 commits intogetmoto:masterfrom
Conversation
AWS DynamoDB Streams does not include OldImage or NewImage keys in
stream records when the corresponding item does not exist:
- INSERT events: no OldImage (there was no previous item)
- REMOVE events: no NewImage (the item was deleted)
Previously, Moto included these keys as empty dicts (e.g. OldImage: {}
on INSERT), which doesn't match AWS behavior. Downstream consumers that
check for the presence of these keys (e.g. `if 'OldImage' in record`)
would incorrectly detect them as present.
The fix adds `and new is not None` / `and old is not None` guards to
the StreamRecord constructor so empty images are omitted entirely.
JackDanger
added a commit
to robotocore/robotocore
that referenced
this pull request
Mar 6, 2026
DynamoDB Streams records incorrectly include empty OldImage/NewImage
keys (e.g. OldImage: {} on INSERT). Fix submitted upstream as
getmoto/moto#9821. Using local vendor/moto with the fix applied.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JackDanger
added a commit
to robotocore/robotocore
that referenced
this pull request
Mar 6, 2026
…w docs - vendor/moto points to fix/dynamodbstreams-omit-empty-images branch (getmoto/moto#9821) which fixes empty OldImage/NewImage on stream records - CLAUDE.md: add parallel worktree, CLI tooling, and subagent workflow docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JackDanger
added a commit
to robotocore/robotocore
that referenced
this pull request
Mar 7, 2026
DynamoDB Streams records incorrectly include empty OldImage/NewImage
keys (e.g. OldImage: {} on INSERT). Fix submitted upstream as
getmoto/moto#9821. Using local vendor/moto with the fix applied.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JackDanger
added a commit
to robotocore/robotocore
that referenced
this pull request
Mar 7, 2026
…w docs - vendor/moto points to fix/dynamodbstreams-omit-empty-images branch (getmoto/moto#9821) which fixes empty OldImage/NewImage on stream records - CLAUDE.md: add parallel worktree, CLI tooling, and subagent workflow docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Fixes stream records to omit
OldImage/NewImagewhen those images don't exist, matching real AWS behavior.OldImagekey absent (was{})NewImagekey absent (was{})Consumers that check
'OldImage' in record['dynamodb']were incorrectly seeing the key on INSERT events.Fix: two
and x is not Noneguards inStreamRecord.__init__().