Skip to content

fix(parser): preserve Lambda tumbling window fields in DynamoDB and Kinesis stream models - #8942

Open
azmi2409 wants to merge 1 commit into
aws-powertools:developfrom
azmi2409:fix-8941-parser-tumbling-window
Open

azmi2409 wants to merge 1 commit into
aws-powertools:developfrom
azmi2409:fix-8941-parser-tumbling-window

Conversation

@azmi2409

@azmi2409 azmi2409 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Issue number: closes #8941

Summary

Changes

DynamoDBStreamModel and KinesisDataStreamModel only defined Records, so Pydantic silently dropped the optional Lambda tumbling window fields (window, state, shardId, eventSourceARN, isFinalInvokeForWindow, isWindowTerminatedEarly) present on DynamoDB Streams and Kinesis Data Streams invocations when tumbling windows are enabled.

  • Added a shared aws_lambda_powertools/utilities/parser/models/tumbling_window.py with:
    • TumblingWindowModel (start / end datetimes)
    • TumblingWindowEventModel base model holding the six optional tumbling window fields, all defaulting to None
  • DynamoDBStreamModel and KinesisDataStreamModel now inherit TumblingWindowEventModel
  • Exported TumblingWindowModel (and TumblingWindowEventModel) from aws_lambda_powertools.utilities.parser.models

Fixes #8941

User experience

Before: parsing a tumbling window event with either model dropped the window fields (hasattr(event, "window") was False).

After: the fields are parsed and exposed, e.g. event.window.start, event.state, event.shardId, event.isFinalInvokeForWindow. Non-tumbling events are unaffected — all new fields default to None.

Verification

  • Reproduced the issue first: new regression tests failed on develop with AttributeError: ... object has no attribute 'window', and pass with the fix (red-proof).
  • New tests in tests/unit/parser/_pydantic/test_dynamodb.py and tests/unit/parser/_pydantic/test_kinesis.py parse the existing tests/events/dynamoStreamTumblingWindowEvent.json and tests/events/kinesisStreamTumblingWindowEvent.json fixtures and assert every tumbling window field, plus assert all fields are None for regular (non-tumbling) stream events.
  • Validated against the real event shape: the fixtures are the repository's recorded Lambda tumbling window events (also covered by the existing data-classes tests, which still pass).
  • Test runs (Python 3.12 venv): tests/unit/parser/_pydantic/test_dynamodb.py, test_kinesis.py, tests/functional/parser/test_model_imports.py, tests/functional/parser/test_parser.py — 92 passed; tests/unit/data_classes/required_dependencies/test_dynamo_db_stream_event.py and test_kinesis_stream_event.py — 14 passed.
  • ruff format --check and ruff check clean on all changed files. mypy reports no errors in the changed files (the only errors are pre-existing missing boto3/botocore stubs in unrelated files, also present on unmodified develop).
  • No docs change: docs/utilities/parser.md lists these models by name only, with no field-level detail to update, and no example covers these fields.

I used an AI coding assistant to help write this fix and the tests, and I reviewed the behaviour and ran all verification myself.

Signed-off-by: Azmi Muwahid azmimuwahid@gmail.com


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@azmi2409
azmi2409 requested a review from a team as a code owner December 2, 2026 13:41
@azmi2409
azmi2409 requested a review from svozza December 2, 2026 13:41
@boring-cyborg boring-cyborg Bot added the tests label Dec 2, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Parser DynamoDBStreamModel and KinesisDataStreamModel drop Lambda tumbling window fields

1 participant