Repository navigation
Match filter_by keys exactly before treating them as globs - #69750
Merged
Merged
Conversation
salt.utils.data.filter_by ran every lookup_dict key through fnmatch.fnmatchcase, so a literal key containing glob metacharacters (the "[" and "]" in GPU/PCI model strings such as "GP104GL [Quadro P4000]") was parsed as a character class and never matched its own value, falling through to the default (saltstack#60976). Try an exact string comparison before the fnmatch fallback. The change is additive: literal keys now match and existing glob patterns are unaffected. This also covers grains.filter_by, pillar.filter_by, and match.filter_by, which all delegate here. Fixes saltstack#60976
twangboy
approved these changes
Jul 15, 2026
dwoz
approved these changes
Aug 7, 2026
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?
Makes
salt.utils.data.filter_bytry an exact key comparison before treating a lookup key as an fnmatch glob, so literal keys that contain glob metacharacters still match their own value.What issues does this PR fix or reference?
Fixes #60976
Previous Behavior
filter_byran everylookup_dictkey throughfnmatch.fnmatchcase, unconditionally treating it as a shell glob. A literal key containing glob metacharacters -- for example the[and]in GPU/PCI model strings likeGP104GL [Quadro P4000]-- was parsed as a character class, so the identical literal key never matched its own value andfilter_byfell through to thedefault. (The reporter attributed this to spaces; the real trigger is the[...]metacharacters.)New Behavior
Keys are matched with an exact string comparison first, then the existing fnmatch glob as a fallback. Literal keys (including ones with glob metacharacters) now match, while existing glob patterns are unchanged. The fix is strictly additive -- it can only make a previously-non-matching literal key match. Because
grains.filter_by,pillar.filter_by, andmatch.filter_byall delegate here, they are all fixed.Merge requirements satisfied?
changelog/60976.fixed.mdtests/pytests/unit/utils/test_data.py: literal key with[...]metacharacters now matches (pins the bug), glob patterns still match, plain literal keys still matchCommits signed with GPG?
No