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
The optional field, output_file, does not behave like an optional field, and the field_validator throws an exception because it does not handle the condition when the output_file is None.
The following error occurs:
\crewai\task.py", line 121, in output_file_validattion
if value.startswith("/"):
AttributeError: 'NoneType' object has no attribute 'startswith'
output_file: Optional[str] =Field(
description="A file path to be used to create a file output.",
default=None,
)
Related Method:
@field_validator("output_file")@classmethoddefoutput_file_validattion(cls, value: str) ->str:
"""Validate the output file path by removing the / from the beginning of the path."""ifvalue.startswith("/"):
returnvalue[1:]
returnvalue
Solution:
@field_validator("output_file")@classmethoddefoutput_file_validattion(cls, value: str) ->str:
"""Validate the output file path by removing the / from the beginning of the path."""ifvalueandvalue.startswith("/"):
returnvalue[1:]
returnvalue
The text was updated successfully, but these errors were encountered:
Maralai
changed the title
BUG: Optional field output_file not optional
BUG+FIX: Optional field output_file not optional
Jul 6, 2024
@joaomdmoura I don't think I will get around to forking the repo and submitting a pull request with the solution stated in this issue at this time. I have, however, rebuilt the distribution and installed it, and the solution resolved the issue.
The optional field, output_file, does not behave like an optional field, and the field_validator throws an exception because it does not handle the condition when the output_file is
None
.The following error occurs:
Example task initialization:
Related Field:
Related Method:
Solution:
The text was updated successfully, but these errors were encountered: