puppetlabs/puppet · error
Could not load --values_file %{error}
Error message
Could not load --values_file %{error} What it means
Logged by Puppet::Face[:epp]#get_values when loading --values_file raises: YAML that Puppet::Util::Yaml.safe_load_file cannot parse or that contains disallowed classes, a .pp file that fails to evaluate, or any I/O error. The exception is swallowed into this message, the values are skipped, and rendering proceeds without them.
Source
Thrown at lib/puppet/face/epp.rb:416
end
end
def get_values(compiler, options)
template_values = nil
values_file = options[:values_file]
if values_file
begin
case values_file
when /\.yaml$/
template_values = Puppet::Util::Yaml.safe_load_file(values_file, [Symbol])
when /\.pp$/
evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new
template_values = evaluating_parser.evaluate_file(compiler.topscope, values_file)
else
Puppet.err(_("Only .yaml or .pp can be used as a --values_file"))
end
rescue => e
Puppet.err(_("Could not load --values_file %{error}") % { error: e.message })
end
unless template_values.nil? || template_values.is_a?(Hash)
Puppet.err(_("--values_file option must evaluate to a Hash or undef/nil, got: '%{template_class}'") % { template_class: template_values.class })
end
end
values = options[:values]
if values
evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new
result = evaluating_parser.evaluate_string(compiler.topscope, values, 'values-hash')
case result
when nil
template_values
when Hash
template_values.nil? ? result : template_values.merge(result)
else
Puppet.err(_("--values option must evaluate to a Hash or undef, got: '%{values_class}'") % { values_class: result.class })
endView on GitHub (pinned to e227c27540)
Solutions
- Syntax-check the YAML: `ruby -ryaml -e 'YAML.load_file("values.yaml")'`
- For .pp values run `puppet parser validate values.pp` and make the file self-contained
- Keep the YAML to plain strings/ints — safe_load permits very few classes
- Fix the underlying error surfaced in the %{error} part of the message and rerun
Example fix
# before (values.yaml) name: app version: 2024-01-01 # Date object rejected by safe_load # after name: app version: "2024-01-01"
Defensive patterns
Strategy: try-catch
Validate before calling
require 'yaml'
begin
YAML.safe_load_file('values.yaml', [Symbol])
rescue StandardError => e
abort "values.yaml not loadable: #{e.message}"
end Try / catch
begin
values = Puppet::Util::Yaml.safe_load_file(path, [Symbol])
rescue StandardError => e
abort "--values_file #{path} failed to load: #{e.message}"
end Prevention
- YAML-lint values files in CI
- Keep values files to plain scalars and mappings — no symbols, dates, or anchors
- Validate .pp values files with `puppet parser validate`
When it happens
Trigger: `puppet epp render tpl.epp --values_file bad.yaml` with a YAML syntax error; a .pp values file referencing undefined variables or functions; Psych::DisallowedClass from symbols/dates in the YAML; Errno::ENOENT for a mistyped path.
Common situations: Hand-edited YAML with tabs or missing colons; values files generated by tools emitting anchors Psych rejects; environment-dependent .pp that works in catalog context but not standalone.
Related errors
- --values_file option must evaluate to a Hash or undef/nil, g
- Could not intern from %{format}: %{err}
- Could not intern_multiple from %{format}: %{err}
- Serialized YAML did not contain a valid instance of %{klass}
- Serialized YAML did not contain a collection of instances wh
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/3e129537769023d5.
Report an issue: GitHub.