Thanks to visit codestin.com
Credit goes to github.com

Skip to content

🐛 Fix support for query parameters with list types, handle JSON encoding Pydantic UndefinedType#9929

Merged
tiangolo merged 4 commits into
fastapi:masterfrom
arjwilliams:bug/json-encode-pydantic-undefined
Apr 18, 2024
Merged

🐛 Fix support for query parameters with list types, handle JSON encoding Pydantic UndefinedType#9929
tiangolo merged 4 commits into
fastapi:masterfrom
arjwilliams:bug/json-encode-pydantic-undefined

Conversation

@arjwilliams

@arjwilliams arjwilliams commented Jul 22, 2023

Copy link
Copy Markdown
Contributor

Related to #9920.

Pydantic recently added new field input to the validation error details. The FastAPI JSON encoder wasn't able to encode the input field when the value was PydanticUndefined, such as the case shown in #9920.

Fix is to encode PydanticUndefined values as None.

@JosephMarinier

Copy link
Copy Markdown

Thanks @arjwilliams! I would love to get that fix!

@tiangolo tiangolo added bug Something isn't working investigate p2 p1 and removed p2 investigate labels Jan 13, 2024

@YuriiMotov YuriiMotov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed this PR. Looks good!

I confirm, that the issue is still relevant to Fatsapi 0.109.2.
This PR fixes problem and does it the right way.
New test fails before changes and passes after.

I also think this issue is quite important, as encountering this problem can lead to a lot of confusion.

@sk-

sk- commented Feb 21, 2024

Copy link
Copy Markdown

@tiangolo is there any chance this PR could get reviewed or alternatively to come up with another fix for #9920?

@tiangolo tiangolo changed the title Handle JSON encoding Pydantic UndefinedType 🐛 Fix support for query parameters with list types, handle JSON encoding Pydantic UndefinedType Apr 18, 2024
@tiangolo

Copy link
Copy Markdown
Member

Great, thank you @arjwilliams! 🚀

I added a couple of extra tests for that specific use case from the issue. 🤓

Thanks all for the feedback and conversation here everyone! ☕

This will be available in FastAPI version 0.110.2 in the next few hours. 🚀

@tiangolo tiangolo merged commit 09e4859 into fastapi:master Apr 18, 2024
hsuanchi pushed a commit to hsuanchi/fastapi that referenced this pull request May 26, 2024
…ing Pydantic `UndefinedType` (fastapi#9929)

Co-authored-by: Andrew Williams <[email protected]>
Co-authored-by: Sebastián Ramírez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants