Conversation
32c906e to
cf8f302
Compare
768dfe9 to
05cb577
Compare
Signed-off-by: Timur Tuktamyshev <timur.tuktamyshev@flant.com>
05cb577 to
89cc022
Compare
ldmonster
approved these changes
Jul 18, 2025
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
juev
pushed a commit
that referenced
this pull request
Jul 29, 2025
Signed-off-by: Timur Tuktamyshev <timur.tuktamyshev@flant.com> Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com> Co-authored-by: Pavel Okhlopkov <pavel.okhlopkov@flant.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.
Overview
This PR enhances the CEL validation logic for OpenAPI schemas in the addon-operator. It introduces recursive validation for all nested properties including for objects with
additionalProperties, arrays, and scalar types at the self level, not just the root level, and refactors error handling in more user-friendly approach, returning multiple validation errors at once instead of returning only first encountered validation error.What this PR does / why we need it
Recursive CEL Validation:
Previously,
x-deckhouse-validationswere only applied at the root level of the schema. Now, the validation logic recursively traverses the entire schema tree, so anyx-deckhouse-validationsdefined at any depth (including deeply nested properties, arrays, and maps viaadditionalProperties) are correctly processed and enforced.Support for Scalar Types and Arrays:
The validation logic now fully supports CEL rules where self is a scalar (e.g., integer, string, boolean) or an array. This enables writing CEL expressions that directly validate scalar fields or perform aggregate checks on arrays (e.g., self.size() > 0, self < 10, etc.).
Improved Error Handling:
The
cel.Validatefunction now returns a slice of validation errors (for failed CEL rules) and a separate technical error (for issues like CEL compilation or type conversion). This makes error reporting more user-friendly.Test Improvements:
Table-driven tests have been updated and expanded to cover cases with nested and deeply nested properties, ensuring that the new recursive validation logic works as intended.
Impact:
With these changes, the product now supports robust, recursive CEL validation for complex and deeply nested configuration schemas. This greatly improves the reliability and correctness of user input validation, allowing module authors to define validation rules at any level of their configuration structure.
Warning
Current code: Does not support
oneOf(oranyOf,allOf).Examples
Before
Validation works correctly, because
x-deckhouse-validationsis defined at root level:Validation doesn't work at all, because
cel.Validatechecks only for root level rules:After
Example with
x-deckhouse-validationsdefined at root level has no changes, still works as intended, but example with nestedx-deckhouse-validationsnow outputs a correct validation error:Not equal to abcSpecial notes for your reviewer