Repository navigation
[master] Fixed issue where dictionary key not exists relied on exception - #64018
tgriffitts-ns wants to merge 3 commits into
Conversation
|
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
There was a problem hiding this comment.
An ignore-whitespace-changes diff on this delta shows much more clearly what is being changed:
@@ -850,8 +850,9 @@
return default
else:
try:
+ if each in ptr:
ptr = ptr[each]
- except KeyError:
+ else:
# Late import to avoid circular import
import salt.utils.args
The whitespaces changes are to indent the existing block of lines, unchanged, which are now under the new if each in ptr: statement.
twangboy
left a comment
There was a problem hiding this comment.
Could you please write some tests and add a changelog.
|
Closing this due to inactivity. Anyone should feel free to re-open it if they want to see it through to the end in one release cycle. @tgriffitts-ns We can re-open this if you want to get it into a release. |
What does this PR do?
It changes the old logic which uses an exception to check if a dictionary key does not exist. This logic is no longer valid. The new YAML loader creates dicts which create and return a default empty value object for keys if they do not yet exist in the dictionary. An exception is no longer thrown if the key does not exist. This patch simply checks if the key exists rather than depending on an exception being thrown if it does not.
What issues does this PR fix or reference?
Fixes:
#64017
Previous Behavior
Lots of bugs are caused by this old code. It manifests when setting multiple salt grains under the same hierarchy in a single highstate
New Behavior
All works as expected
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes/No
Please review Salt's Contributing Guide for best practices.
See GitHub's page on GPG signing for more information about signing commits with GPG.