fix: prevent empty defaults/overrides dicts in policy spec#880
Open
fix: prevent empty defaults/overrides dicts in policy spec#880
Conversation
Contributor
Author
|
/make kuadrant |
1 similar comment
Contributor
Author
|
/make kuadrant |
|
Test run has started ( |
|
Test run has started ( |
Contributor
Author
|
/make kuadrant |
ed40602 to
db55b43
Compare
Contributor
Author
|
/make kuadrant |
|
Test run has started ( |
Contributor
Author
|
/make kuadrant |
1 similar comment
Contributor
Author
|
/make kuadrant |
|
Test run has started ( |
silvi-t
reviewed
Mar 10, 2026
silvi-t
reviewed
Mar 10, 2026
silvi-t
reviewed
Mar 10, 2026
averevki
reviewed
Mar 10, 2026
190a6de to
15ef176
Compare
bafe6fd to
f14e9ad
Compare
Signed-off-by: Alexander Cristurean <acristur@redhat.com>
averevki
reviewed
Mar 17, 2026
Comment on lines
+58
to
+62
| if isinstance(self.spec_section, str): | ||
| # String marker - create the section now | ||
| section = self.model.spec.setdefault(self.spec_section, {}) | ||
| else: | ||
| section = self.spec_section |
Contributor
There was a problem hiding this comment.
Suggested change
| if isinstance(self.spec_section, str): | |
| # String marker - create the section now | |
| section = self.model.spec.setdefault(self.spec_section, {}) | |
| else: | |
| section = self.spec_section | |
| section = self.spec_section | |
| if isinstance(self.spec_section, str): | |
| # String marker - create the section now | |
| section = self.model.spec.setdefault(self.spec_section, {}) |
better code flow 👍
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
AuthPolicywhere accessingdefaultsoroverridesproperties would immediately create empty dicts in the spec, even when no rules were addeddefaults: {}oroverrides: {}sections from appearing in committed AuthPolicy specsChanges
Bug Fix
defaultsandoverridesproperties to use string markers ("defaults","overrides") instead of immediately callingsetdefault()auth_sectionproperty to check for string markers and only create the dict when actually neededstrategy()method to handle string markers and create the section dict on-demandTechnical Details
The previous implementation would create empty dicts when accessing properties:
New implementation uses lazy initialization:
self.spec_section = "defaults" # Just a marker, no dict created yet
The actual dict is only created when auth_section or strategy() is called to add actual configuration.
Verification steps
No test files were modified. Existing tests verify the fix:
Test defaults/overrides exclusivity rules
poetry run pytest -vv testsuite/tests/singlecluster/defaults/test_rules_exclusivity.py testsuite/tests/singlecluster/overrides/test_rules_exclusivity.py
Test that defaults/overrides functionality still works
poetry run pytest -vv testsuite/tests/singlecluster/defaults/ testsuite/tests/singlecluster/overrides/