Improve edge case validation for GeneralConfig.get_num_threads
#22
Labels
bug
Something isn't working
GeneralConfig.get_num_threads
#22
There is a minor input validation bug for src/cve/data_models/config.py
GeneralConfig.get_num_threads
:The field validator appears to expect invalid values:
However this runs after Pydantic's own
PositiveInt
validator. So the validator effectively does nothing andGeneralConfig(num_threads=None)
will raise aValidationError
. Setting@field_validator("num_threads", mode="before")
fixes the issue.The reason we need the field validator:
os.cpu_count()
sometimes returns None, the validator will supply a value of 1 in that situationos.cpu_count()
The text was updated successfully, but these errors were encountered: