Repository navigation
[3006.x] Ensure dunder global NamedLoaderContext obj's value() is used, when passing outside of execution modules - #64055
Merged
Conversation
dwoz
previously requested changes
Apr 12, 2023
s0undt3ch
suggested changes
Apr 12, 2023
s0undt3ch
suggested changes
Apr 12, 2023
dmurphy18
force-pushed
the
fix_62477
branch
2 times, most recently
from
April 13, 2023 01:01
6a02da4 to
c0054d8
Compare
s0undt3ch
previously approved these changes
Apr 13, 2023
Contributor
Author
|
Moving this to 3006.1, to allow for more time to research NamedLoaderContext issue not containing a loader which results in None. |
dmurphy18
force-pushed
the
fix_62477
branch
2 times, most recently
from
April 18, 2023 23:10
2d24bc0 to
4c653d8
Compare
dwoz
previously approved these changes
Apr 25, 2023
dwoz
left a comment
Contributor
There was a problem hiding this comment.
This just needs a regression test.
Contributor
Author
|
Fortunately have one almost written :) |
added 9 commits
April 25, 2023 14:51
… reviewer comments
Contributor
Author
|
Test added |
dwoz
approved these changes
Apr 26, 2023
twangboy
approved these changes
Apr 26, 2023
garethgreenaway
approved these changes
Apr 26, 2023
1 of 6 tasks
This was referenced Nov 23, 2026
dwoz
added a commit
to dwoz/salt
that referenced
this pull request
Nov 23, 2026
…tack#65504) salt '*' config.items and similar minion jobs crashed on the master with AttributeError: 'NoneType' object has no attribute '__iter__' when a NamedLoaderContext whose value() returned None was included in the returned payload. salt.payload.dumps msgpack-encodes any collections.abc.MutableMapping via dict(obj), which iterates via __iter__ -> self.value().__iter__(). Off-context, the four mapping- typed dunders fell back to the construction default of None and crashed at that dict() call. Fix at the dunder construction site in salt.loader.dunder: pass default={} for the mapping-typed dunders (__opts__, __context__, __pillar__, __grains__). value() now returns an empty mapping off-context, honoring the MutableMapping contract the class advertises. __file_client__ stays default=None: it is not a mapping, and None is its documented 'no file client' sentinel. Reviewers of saltstack#64055 (April 2023) deliberately removed the earlier NamedLoaderContext branch in salt.payload.dumps and directed the fix to the loader layer; this change respects that direction.
This branch was previously deployed
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?
Checks that the NamedLoaderContext object used does not generate a None before attempting to use it to create a dictionary
What issues does this PR fix or reference?
Fixes: #62477
Previous Behavior
The code would throw an exception due to effectively executing dict(None) from a NamedLoaderContext object.
New Behavior
Ensure that NamedLoaderContext objects used with dunder globals, typically grains and pillar, have their 'value(). used to pass their contents rather than the NamedLoaderContext object when the value is passed to other modules, for example: pillar, utils, etc.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.