{"record":{"id":"4a3cf757aa4f6949","repo":"puppetlabs/puppet","slug":"invalid-environment-setting-value","errorCode":null,"errorMessage":"Invalid environment setting '%{value}'","messagePattern":"Invalid environment setting '%(.+?)'","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/type/exec.rb","lineNumber":309,"sourceCode":"        must fully qualify the command's name.\"\n\n      validate do |command|\n        provider.validatecmd(command)\n      end\n    end\n\n    newparam(:environment) do\n      desc \"An array of any additional environment variables you want to set for a\n        command, such as `[ 'HOME=/root', 'MAIL=root@example.com']`.\n        Note that if you use this to set PATH, it will override the `path`\n        attribute. Multiple environment variables should be specified as an\n        array.\"\n\n      validate do |values|\n        values = [values] unless values.is_a? Array\n        values.each do |value|\n          unless value =~ /\\w+=/\n            raise ArgumentError, _(\"Invalid environment setting '%{value}'\") % { value: value }\n          end\n        end\n      end\n    end\n\n    newparam(:umask, :required_feature => :umask) do\n      desc \"Sets the umask to be used while executing this command\"\n\n      munge do |value|\n        if value =~ /^0?[0-7]{1,4}$/\n          return value.to_i(8)\n        else\n          raise Puppet::Error, _(\"The umask specification is invalid: %{value}\") % { value: value.inspect }\n        end\n      end\n    end\n\n    newparam(:timeout) do","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/type/exec.rb#L291-L327","documentation":"The exec type's environment parameter takes a string or array of KEY=value settings; validate requires every entry to match /\\w+=/ (a word followed by '='). Entries lacking an '=' (bare 'FOO', empty strings, symbols or numbers whose Object#=~ yields nil) raise ArgumentError 'Invalid environment setting'. The match is an unanchored substring test, so 'A=1 B=2' passes as one string, but 'FOO' does not.","triggerScenarios":"environment => 'FOO' (no '='), environment => ['HOME=/root', 42], environment => :PATH (Symbol), or entries derived from structured data where only the key name was joined. Also strings like '=bar' where no word character precedes the '='.","commonSituations":"Building environment entries from hashes and forgetting to join ('%s=%s' % [k, v]); data-driven execs taking env lists from hiera where an entry lost its value; copying docker-compose style env lists (plain names) into Puppet.","solutions":["Format every entry as KEY=value: environment => ['HOME=/root', 'MAIL=root@example.com']","When mapping a hash, join explicitly: $env = $vars.map |$k, $v| { \"${k}=${v}\" }","Drop empty/nil entries before assignment: $vars.filter |$e| { $e =~ /\\w+=/ }","Remember PATH set here overrides the exec path parameter"],"exampleFix":"# before\nexec { 'deploy': command => '/bin/deploy', environment => $env_vars } # $env_vars = ['FOO', 'BAR=1'] => ArgumentError\n\n# after\n$env_vars = {'FOO' => 'x', 'BAR' => '1'}\nexec { 'deploy': command => '/bin/deploy', environment => $env_vars.map |$k, $v| { \"${k}=${v}\" } }","handlingStrategy":"validation","validationCode":"$env = $vars.map |$k, $v| { \"${k}=${v}\" }\n# or in Ruby:\nvalues = [values] unless values.is_a?(Array)\nbad = values.reject { |v| v.is_a?(String) && v =~ /\\w+=/ }\nraise ArgumentError, \"bad environment entries: #{bad.inspect}\" unless bad.empty?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build KEY=value strings explicitly with map/join instead of passing raw names","Filter out nil/empty entries from data before assignment","Remember PATH in environment overrides the path parameter"],"tags":["puppet","exec","environment","attribute-format","key-value"],"backgroundTag":"invalid-attribute-format","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}