hyperglass icon indicating copy to clipboard operation
hyperglass copied to clipboard

Fix validation in directives and devices

Open Computroniks opened this issue 10 months ago • 0 comments

Description

This PR fixes multiple validation related issues

  1. Some of the field validator methods for device config used values as a dictionary (presumably from an old version of pydantic). This is now passed as a ValidationInfo object by pydantic, which caused issues when code attempted to access it. The affected methods have been updated to fix the issue.
  2. 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.
  3. Update docs so they include required options for field in the examples.
  4. Fixed API docs rendering. The use of strip_whitespace in Field for the query validation model caused the automatic generation of the API docs to fail with ValueError: schema_extradeclares keystrip_whitespacewhich does not exist inSchema object. By switching from Field to Annotated with StringConstraints, 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.

Computroniks avatar Jun 04 '25 12:06 Computroniks