FigmaChain icon indicating copy to clipboard operation
FigmaChain copied to clipboard

PydanticUserError: If you use `@root_validator` with pre=False (the default) you MUST specify `skip_on_failure=True`.

Open lolliuym opened this issue 2 years ago • 5 comments

The error message you're seeing indicates that there is an issue with the usage of the @root_validator decorator from the Pydantic library. Starting from version 2.0.2, if you use @root_validator with pre=False (which is the default behavior), you must specify skip_on_failure=True to avoid this error.

File containing root_validator not found !

image

lolliuym avatar Jul 12 '23 10:07 lolliuym

the tips below didn't help:

To resolve this issue, you have a few options:

  1. Update Pydantic: Make sure you have the latest version of Pydantic installed. You can use pip install --upgrade pydantic to upgrade to the latest version.

  2. Replace @root_validator with @model_validator: As mentioned in the error message, @root_validator is deprecated and should be replaced with @model_validator. Update your code to use @model_validator instead.

  3. Specify skip_on_failure=True: If you want to continue using @root_validator, you can add the skip_on_failure=True parameter to the decorator. This will prevent the error from occurring. For example:

@root_validator(pre=False, skip_on_failure=True) def my_validator(cls, values): # Your validation logic here return values

Someone please help me in fixing this.

Thanks in advance :).

lolliuym avatar Jul 12 '23 10:07 lolliuym

I keep getting the same error. Does anyone have a solution please?

JhdChk avatar Aug 08 '23 12:08 JhdChk

Use pydantic following version Pydantic==1.10.7

Shaon2221 avatar Oct 04 '23 04:10 Shaon2221

I fixed this issue by using below command to install pydantic.

pip install pydantic==1.10.7

jeanru avatar Nov 08 '23 05:11 jeanru

Now, Im getting: ImportError: cannot import name 'AfterValidator' from 'pydantic' (C:\Users\b..\Lib\site-packages\pydantic_init_.cp311-win_amd64.pyd)

AkanimohOD19A avatar Jul 28 '24 21:07 AkanimohOD19A