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
Describe the bug
In the __init__ method of PydanticFieldValidator, the kwarg field_validator is not passed along in the super call as follows: super().__init__(on_fail, **kwargs).
This causes the argument field_validator to not propagate through all the future calls, causing the runtime validator initialization to fail with the following error:
Define the Pydantic class and add the PydanticFieldValidator for a field as follows: field_name: int = Field(description="Some description", validators=[PydanticFieldValidator(field_validator=your_validation_function, on_fail="fix")])
Initialise the guard as follows: guard = gd.Guard.from_pydantic(output_class=<PydanticClassName>, prompt=prompt)
Expected behavior
The error should not be raised.
Library version:
v0.3.2 (Latest version as of now)
Probable fix
Like in the __init__ methods for all other validators, we explicitly pass in the required argument in the super call alongwith any other kwargs as follows:
Describe the bug
In the
__init__
method ofPydanticFieldValidator
, the kwargfield_validator
is not passed along in the super call as follows:super().__init__(on_fail, **kwargs)
.Location:
guardrails/guardrails/validators/pydantic_field_validator.py
Lines 32 to 39 in 8833c05
This causes the argument
field_validator
to not propagate through all the future calls, causing the runtime validator initialization to fail with the following error:To Reproduce
Steps to reproduce the behavior:
prompt
PydanticFieldValidator
for a field as follows:field_name: int = Field(description="Some description", validators=[PydanticFieldValidator(field_validator=your_validation_function, on_fail="fix")])
guard = gd.Guard.from_pydantic(output_class=<PydanticClassName>, prompt=prompt)
Expected behavior
The error should not be raised.
Library version:
v0.3.2 (Latest version as of now)
Probable fix
Like in the
__init__
methods for all other validators, we explicitly pass in the required argument in the super call alongwith any other kwargs as follows:The text was updated successfully, but these errors were encountered: