-
Notifications
You must be signed in to change notification settings - Fork 421
Bug: DynamoDBStreamChangedRecordModel doesn't deserialize ApproximateCreationDateTime with time components when using Pydantic V2 #3048
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
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Hey @waveFrontSet! Thanks for reporting this possible bug. I'm looking at this now. |
Hi @waveFrontSet! Yes, I can confirm that it is a bug and we need to fix it. Promoting the field to I completely agree that we need to fix our tests to test this field, which is not happening today. So do you want to send a PR for this? Do you want me to fix it myself? We plan to launch a release on Friday, but if this is too urgent for you, we may be able to move this up to tomorrow. Thanks. |
Hi @leandrodamascena, |
Great @waveFrontSet! When you send the PR I can review and merge it. |
|
Expected Behaviour
DynamoDB Stream events with
ApproximateCreationDateTime
with time components should be deserialized.Current Behaviour
In v2, pydantic raises the validation error date_from_datetime_inexact. In v1, pydantic drops time components silently when parsing timestamps into
date
objects.Code snippet
Possible Solution
The simplest solution probably is to promote ApproximateCreationDateTime to an
Optional[datetime]
instead ofOptional[date]
.The test events in dynamoStreamEvent.json don't contain the attribute which is probably why this wasn't caught during the pydantic v2 upgrade.
Steps to Reproduce
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
PyPi
Debugging logs
The text was updated successfully, but these errors were encountered: