Repository navigation
Conversation
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. Fix thatmattlove#311 Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
Previously, when processing rules with no condition, an extra RuleWithPattern rule was also added to the rule list causing a validation error. This has been corrected. Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
Computroniks
force-pushed
the
computroniks/bug/#311-fix-field-validation
branch
from
June 4, 2025 17:35
ca3c542 to
f49ff54
Compare
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_extra` declares key `strip_whitespace` which does not exist in `Schema` object`. By switching from `Field` to `Annotated` with `StringConstraints`, this avoids this issue allowing API docs to be correctly rendered. Signed-off-by: Mattie Nickson <mnickson@sidingsmedia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes multiple validation related issues
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.fieldin the examples.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.