You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With pydantic 1.5 I've run into some issues with shared fields in different models. Unfortunately I can only recreate the issue when using the models in fastAPI endpoints. It's definitely a change in pydantic that introduced the issue (if I downgrade back to 1.4, the issue disappears), but it might be due to some quirky way that fastAPI is using pydantic models. In that case I'm happy to reraise the issue in the fastAPI project.
The problem I'm seeing is that if I reuse a required Field(...) in two separate models, only the first model correctly tells me that a required input is missing. The second model gets (incorrectly) instantiated with the required value set to None.
Maybe you can think of some change to Field between 1.4 and 1.5 that could be behind this weird behavior? If not I'm happy to try and isolate the problem some more and look into exactly how fastAPI is using the pydantic models and what might go wrong there.
Thanks in advance for any help.
The text was updated successfully, but these errors were encountered:
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:With
pydantic
1.5 I've run into some issues with shared fields in different models. Unfortunately I can only recreate the issue when using the models infastAPI
endpoints. It's definitely a change inpydantic
that introduced the issue (if I downgrade back to 1.4, the issue disappears), but it might be due to some quirky way thatfastAPI
is using pydantic models. In that case I'm happy to reraise the issue in thefastAPI
project.The problem I'm seeing is that if I reuse a required
Field(...)
in two separate models, only the first model correctly tells me that a required input is missing. The second model gets (incorrectly) instantiated with the required value set toNone
.Now if you fire some requests, you can see the weird difference in behavior between the
/expected
and/unexpected
endpoint.Maybe you can think of some change to
Field
between 1.4 and 1.5 that could be behind this weird behavior? If not I'm happy to try and isolate the problem some more and look into exactly howfastAPI
is using the pydantic models and what might go wrong there.Thanks in advance for any help.
The text was updated successfully, but these errors were encountered: