{"record":{"id":"3e129537769023d5","repo":"puppetlabs/puppet","slug":"could-not-load-values-file-error","errorCode":null,"errorMessage":"Could not load --values_file %{error}","messagePattern":"Could not load --values_file %(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/puppet/face/epp.rb","lineNumber":416,"sourceCode":"    end\n  end\n\n  def get_values(compiler, options)\n    template_values = nil\n    values_file = options[:values_file]\n    if values_file\n      begin\n        case values_file\n        when /\\.yaml$/\n          template_values = Puppet::Util::Yaml.safe_load_file(values_file, [Symbol])\n        when /\\.pp$/\n          evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new\n          template_values = evaluating_parser.evaluate_file(compiler.topscope, values_file)\n        else\n          Puppet.err(_(\"Only .yaml or .pp can be used as a --values_file\"))\n        end\n      rescue => e\n        Puppet.err(_(\"Could not load --values_file %{error}\") % { error: e.message })\n      end\n      unless template_values.nil? || template_values.is_a?(Hash)\n        Puppet.err(_(\"--values_file option must evaluate to a Hash or undef/nil, got: '%{template_class}'\") % { template_class: template_values.class })\n      end\n    end\n\n    values = options[:values]\n    if values\n      evaluating_parser = Puppet::Pops::Parser::EvaluatingParser.new\n      result = evaluating_parser.evaluate_string(compiler.topscope, values, 'values-hash')\n      case result\n      when nil\n        template_values\n      when Hash\n        template_values.nil? ? result : template_values.merge(result)\n      else\n        Puppet.err(_(\"--values option must evaluate to a Hash or undef, got: '%{values_class}'\") % { values_class: result.class })\n      end","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/face/epp.rb#L398-L434","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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"],"exampleFix":"# before (values.yaml)\nname: app\nversion: 2024-01-01   # Date object rejected by safe_load\n\n# after\nname: app\nversion: \"2024-01-01\"","handlingStrategy":"try-catch","validationCode":"require 'yaml'\n\nbegin\n  YAML.safe_load_file('values.yaml', [Symbol])\nrescue StandardError => e\n  abort \"values.yaml not loadable: #{e.message}\"\nend","typeGuard":null,"tryCatchPattern":"begin\n  values = Puppet::Util::Yaml.safe_load_file(path, [Symbol])\nrescue StandardError => e\n  abort \"--values_file #{path} failed to load: #{e.message}\"\nend","preventionTips":["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`"],"tags":["ruby","puppet","yaml","epp","values-file","parse-error"],"backgroundTag":"config-file-parse-error","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}