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
ValidationError.from_exception_data doesn't work with error type: 'ip_v4_address'" #963
Comments
I'm running into a similar issue where Reproducing the Errors:
(2) value_error
Expected Behavior: Instead of the TypeErrors raised above, I expect a pydantic ValidationError to be raised that shows relevant info for the respective
Versions: |
I am having the same issues. The new things like @model_validator are an exciting direction, but we really need support on how to properly aggregate custom errors in this case. When trying to aggregate errors, I am really struggling. Is this a sign I am using pydantic not as intended? if not, are there more complex cases in the docs? If I am using this as intended, here were debug steps I looked at the Init error typed dict..... nothing jumps out as to what was wrong in my case.
|
It's complaining about there being no e.g. ...
InitErrorDetails(
{
"type": "value_error",
"loc": (info.field_name,),
"input": v,
"ctx": {
"error": f"your_message {v}",
},
}
) edit Also, depending on the As far as I know, you can inspect what needs to be in the from pydantic_core._pydantic_core import list_all_errors
list_all_errors() |
Describe the bug
When constructing validation errors using
ValidationError.from_exception_data
, this fails when the error type isip_v4_address
.It will raise:To Reproduce
Run the code below. It uses a custom model validator that manually constructs the validation error using
ValidationError.from_exception_data
Expected behavior
Pydantic is capable of generating 'ip_v4_address' errors when using model validation without the custom model validator. Therefore, we should be able to manually construct the validation error using the error dictionary that contains the ip_v4_address error type as input into
ValidationError.from_exception_data
.If you were to remove the custom model validator in the example above, Pydantic would successfully throw that error type:
Haven't tested it, but should ip_v4_address be in this error list here?
https://github.com/pydantic/pydantic-core/blob/main/python/pydantic_core/core_schema.py#L3900
Version:
The text was updated successfully, but these errors were encountered: