Fix Thorium reg.list crashing on a non-list, non-string value#69692
Open
ggiesen wants to merge 2 commits into
Open
Fix Thorium reg.list crashing on a non-list, non-string value#69692ggiesen wants to merge 2 commits into
ggiesen wants to merge 2 commits into
Conversation
reg.list_() called add.split(",") whenever add was not a list, which
raised "AttributeError: 'int' object has no attribute 'split'" when an
integer (or other scalar) was passed via SLS. Only split strings and
wrap any other non-list scalar in a single-element list instead.
Fixes saltstack#43364
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.
What does this PR do?
salt/thorium/reg.py list_() called add.split(",") whenever add was not a list, so an integer add (e.g. "add: 42" in SLS) raised AttributeError: 'int' object has no attribute 'split'. Fixed by only splitting when add is a str and wrapping any other non-list scalar as [add]. Added tests/pytests/unit/thorium/test_reg.py (new dir + init.py) exercising list_ directly with reg.reg/events dunders set on the module (the saltfactories loader-mock fixture rejects thorium's non-standard reg/events dunders). Verified the shadow import points at the worktree, both tests pass with the fix, and test_list_integer_add fails with the exact reported AttributeError when the fix is reverted. Note: the shared venv's saltfactories log-server plugin hangs at session start and its system-statistics plugin errors, so both were disabled via -p no: for this pure-python unit test.
What issues does this PR fix or reference?
Fixes #43364
Previous Behavior
See #43364.
New Behavior
Fix Thorium reg.list crashing on a non-list, non-string value. Validated by a unit test proven to fail on unpatched 3006.x and pass with the fix (confirmed by adversarial review).
Merge requirements satisfied?
Commits signed with GPG?
No