Issue #12479 has been updated by Daniel Pittman. Subject changed from Regression: Regex matching against non-existant facts results in false-positive to Regular expression matching against an undefined variable results in matching the string `undef` Description updated Category set to parser Status changed from Unreviewed to In Topic Branch Pending Review Target version set to 2.7.x Affected Puppet version set to 2.6.0 Branch set to https://github.com/puppetlabs/puppet/pull/470
Jonathan Boyett wrote: > ↑ This is funny. I think you misspelled "humiliating" there. ;) So, it turns out this comes from some other deliberate behaviour: https://github.com/puppetlabs/puppet/commit/53869e99149be0f60b4e415d061a76ab5421eadb A sorry side effect of that is that the regexp match turns it into a string, and matches on that, even though it shouldn't. Matching undef against a literal string defines `undef == ""`, so for consistency in the 2.7 branch I am going to define `undef =~ /^$/` - it matches the literal empty string also. Arguments that this undef == empty string behaviour is insane happily accepted on another ticket. (eg: #6745, but there are doubtless others :) https://github.com/puppetlabs/puppet/pull/470 contains the fix, if anyone wants to go ahead and test this before we merge it, but it restore the old (and saner) behaviour. Now your 0.25 idiom will actually work. (Also, we have some tests, so it won't break again accidentally.) ---------------------------------------- Bug #12479: Regular expression matching against an undefined variable results in matching the string `undef` https://projects.puppetlabs.com/issues/12479 Author: Nicolas Simonds Status: In Topic Branch Pending Review Priority: Normal Assignee: Category: parser Target version: 2.7.x Affected Puppet version: 2.6.0 Keywords: Branch: https://github.com/puppetlabs/puppet/pull/470 Non-existent variables are stringify-ing under the hood as `"undef"`, which causes them to match regexes, despite behaving like nil or the empty string when otherwise asked. A simple demonstration manifest: <pre> case $wtf { "undef": { notice("matched string undef") } } case $wtf { /^undef$/: { notice("matched regexp undef") } } case $wtf { "": { notice("matched empty string") } } case $wtf { undef: { notice("matched bareword undef") } } </pre> Expected result: All notices that the non-existent fact or variable doesn't match. Actual result: Various and sundry notices that it matched. BAD PUPPET! NO COOKIE! All die of embarrassment. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
