Repository navigation
Conversation
|
This branch has not been deployed
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.



Issue number: closes #8936
Summary
Changes
PydanticSerializer.to_dict()now dumps withby_alias=True, so the stored dict is whatmodel_validate()accepts for models with field aliases. No change tofrom_dict(): records already stored forpopulate_by_name=Truemodels still validate by field name, and models without aliases dump the same dict as before.User experience
Before, a function decorated with
@idempotent_function(..., output_serializer=PydanticSerializer)worked on the first call but every repeated call with the same idempotency key raisedValidationErrorwhen the return model used a field alias (Field(alias="orderId")oralias_generator=to_camel) withoutpopulate_by_name=True. After, the repeated call returns the saved model, the same as the first call.Verification
I reproduced the issue with the snippet from the report and confirmed the second call raised
ValidationErrorbefore the fix and returns the saved model after it. I addedtest_pydantic_serializer_round_trips_field_aliases, which round-trips three models (explicit alias,alias_generator=to_camel, andpopulate_by_name=Trueas the already-working control) throughto_dictplus JSON and back throughfrom_dict. Without the fix the first two cases fail and the control passes; with the fix all three pass.Focused tests, run by me:
ruff checkandruff format --checkpass on the changed files. No docs change: the fix restores the round-trip the serializer already promises. I used an AI assistant to write this PR, and I ran the verification above myself.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.