hyperglass
hyperglass copied to clipboard
Fix validation in directives and devices
Description
This PR fixes multiple validation related issues
- Some of the field validator methods for device config used
valuesas a dictionary (presumably from an old version of pydantic). This is now passed as aValidationInfoobject by pydantic, which caused issues when code attempted to access it. The affected methods have been updated to fix the issue. - Previously, when processing rules with no condition, an extra RuleWithPattern rule was also added to the rule list causing a validation error. This behaviour has been prevented meaning only a RuleWithoutValidation rule is added.
- Update docs so they include required options for
fieldin the examples. - Fixed API docs rendering. The use of
strip_whitespaceinFieldfor the query validation model caused the automatic generation of the API docs to fail withValueError:schema_extradeclares keystrip_whitespacewhich does not exist inSchemaobject. By switching fromFieldtoAnnotatedwithStringConstraints, this avoids this issue allowing API docs to be correctly rendered.
Related Issues
Fix #311
Motivation and Context
I am currently deploying hyperglass and have run into a few issues with config validation and I am fixing them as I encounter them.
Previously hyperglass would crash when starting with various configurations.
Tests
Manual testing of fixes before and after to ensure issues do not persist after change.