Skip to content

Conversation

dreglad
Copy link
Contributor

@dreglad dreglad commented May 19, 2025

This PR fixes the serialization of zero-value Pendulum durations. Previously, serializing a zero duration produced the invalid ISO 8601 string 'P', which caused validation errors on deserialization. Now, zero durations are correctly serialized as 'P0D'.

Before

TestModel(delta_t=Duration(0)).model_dump_json()
# Output: {"delta":"P"}
# Validation error on reload

After

TestModel(delta_t=Duration(0)).model_dump_json()
# Output: {"delta":"P0D"}
# No validation error

Copy link
Collaborator

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@yezz123 yezz123 merged commit cdd564f into pydantic:main May 19, 2025
10 checks passed
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