puppetlabs/puppet · error

--- #{filename}

Error message

--- #{filename}

What it means

Printed by the `puppet epp validate` face while validating several templates: when a file raises Puppet::ParseError and show_filename is on, Puppet.err emits '--- <filename>' as a header, then the parse error message, and that file's result becomes ''. It is the multi-file error banner for EPP syntax failures, not an error in itself.

Source

Thrown at lib/puppet/face/epp.rb:394

      if show_filename && options[:header]
        output << "--- #{filename}\n"
      end
      fmt = options[:format]
      if fmt.nil? || fmt == 'old'
        output << Puppet::Pops::Model::ModelTreeDumper.new.dump(parse_result) << "\n"
      else
        require_relative '../../puppet/pops/pn'
        pn = Puppet::Pops::Model::PNTransformer.transform(parse_result)
        case fmt
        when 'json'
          options[:pretty] ? JSON.pretty_unparse(pn.to_data) : JSON.dump(pn.to_data)
        else
          pn.format(options[:pretty] ? Puppet::Pops::PN::Indent.new('  ') : nil, output)
        end
      end
    rescue Puppet::ParseError => detail
      if show_filename
        Puppet.err("--- #{filename}")
      end
      Puppet.err(detail.message)
      ""
    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

View on GitHub (pinned to e227c27540)

Solutions

  1. Read the line printed right after the header — it carries the actual parse error and its position
  2. Open the named template and fix the EPP syntax
  3. Iterate with `puppet epp validate <single file>` until clean, then rerun the batch
  4. Add `puppet epp validate` to module CI so broken templates never land

Example fix

# before (bad.epp)
<%= 1 + 

# after
<%= 1 + 1 %>
Defensive patterns

Strategy: try-catch

Validate before calling

require 'puppet/pops/parser/evaluating_parser'

parser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new
begin
  parser.parse_file('template.epp')
  puts 'template OK'
rescue Puppet::ParseError => e
  puts "#{e.file}:#{e.line} #{e.message}"
end

Try / catch

files.each do |f|
  begin
    validate_template(f)
  rescue Puppet::ParseError => e
    Puppet.err "--- #{f}"      # same convention the face uses
    Puppet.err e.message
    bad << f                    # keep going, collect failures for the summary
  end
end

Prevention

When it happens

Trigger: `puppet epp validate a.epp b.epp c.epp` (or a glob of templates) where at least one template has invalid EPP: unbalanced <%= %>, invalid Puppet expressions inside tags, or a stray %>.

Common situations: Hand-edited or ERB-converted templates; CI running epp validate over a module's templates; templates using syntax only valid in newer Puppet versions.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/b74026e0fb9cb9f9. Report an issue: GitHub.