From c5241901e91d636eed3104690f7b50a254946b0a Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Wed, 15 Oct 2025 12:37:04 -0700 Subject: [PATCH] Allow multivalue parameters to be deferred lazily Before this change, values returned from a deferred function would be wrapped inside an array when resolved lazily (with the default setting `preprocess_deferred=false`.) The resolution functions didn't detect this and the value was not resolved before the resource was enforced. That error case didn't occur when preprocessing, which just enumerated all values and resolved them before entering the resolution lifecycle. This change just avoids wrapping in an extra array. It expects the function itself to return an array and will fail with an appropriate error during catalog enforcement if it does not. Example: ``` Notice: Compiled catalog for waffles.localdomain in environment production in 0.01 seconds Error: Failed to apply catalog: value returned from function 'expand_groups' has wrong type, expects an Array value, got Integer ``` Fixes #213 --- lib/puppet/property.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb index 757fffa5ff..3df3c46847 100644 --- a/lib/puppet/property.rb +++ b/lib/puppet/property.rb @@ -526,7 +526,7 @@ def should devfail "should for #{self.class.name} on #{resource.name} is not an array" unless @should.is_a?(Array) - if match_all? + if match_all? and ! (@should.one? and @should.first.instance_of? Puppet::Pops::Evaluator::DeferredValue) @should.collect { |val| unmunge(val) } else unmunge(@should[0])