From cce67b42bb6d09d4e9773b64e28c07d8a93ed088 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 4 Oct 2016 09:36:20 +0100 Subject: Permit undef passed as `nil` to validate_string When validate_string is called via the Puppet 4 deprecation wrappers from deprecation_gen (introduced in 970852d), `undef` is passed as `nil` where it was previously passed as `''` from the Puppet 3-style function API. This change explicitly permits a `nil` value in validate_string, and adds a test case to `is_string` which also accepts the same. Fixes test failures in apt, concat etc: Error while evaluating a Function Call, nil is not a string. It looks to be a NilClass at apt/manifests/source.pp:23:3 [..] # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:34:in `block (2 levels) in ' # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:32:in `each' # ./spec/fixtures/modules/stdlib/lib/puppet/parser/functions/validate_string.rb:32:in `block in ' # puppet-4.7.0/lib/puppet/parser/functions.rb:174:in `block (2 levels) in newfunction' # puppet-4.7.0/lib/puppet/util/profiler/around_profiler.rb:58:in `profile' # puppet-4.7.0/lib/puppet/util/profiler.rb:51:in `profile' # puppet-4.7.0/lib/puppet/parser/functions.rb:167:in `block in newfunction' # ./spec/fixtures/modules/stdlib/lib/puppet_x/puppetlabs/stdlib/deprecation_gen.rb:13:in `block (2 levels) in deprecation_gen' --- lib/puppet/parser/functions/validate_string.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/parser/functions/validate_string.rb b/lib/puppet/parser/functions/validate_string.rb index e92a2fc..0057fc1 100644 --- a/lib/puppet/parser/functions/validate_string.rb +++ b/lib/puppet/parser/functions/validate_string.rb @@ -30,7 +30,7 @@ module Puppet::Parser::Functions end args.each do |arg| - unless arg.is_a?(String) + unless arg.is_a?(String) || arg.nil? raise Puppet::ParseError, ("#{arg.inspect} is not a string. It looks to be a #{arg.class}") end end -- cgit v1.2.3