{"record":{"id":"518cc05708193847","repo":"puppetlabs/puppet","slug":"errors-while-validating-epp","errorCode":null,"errorMessage":"Errors while validating epp","messagePattern":"Errors while validating epp","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/face/epp.rb","lineNumber":101,"sourceCode":"\n      missing_files = []\n      files.each do |file|\n        break if !status && !options[:continue_on_error]\n\n        template_file = effective_template(file, compiler.environment)\n        if template_file\n          tmp = validate_template(template_file)\n          status &&= tmp\n        else\n          missing_files << file\n        end\n      end\n      if !missing_files.empty?\n        raise Puppet::Error, _(\"One or more file(s) specified did not exist:\\n%{missing_files_list}\") %\n                             { missing_files_list: missing_files.map { |f| \"   #{f}\" }.join(\"\\n\") }\n      else\n        # Exit with 1 if there were errors\n        raise Puppet::Error, _(\"Errors while validating epp\") unless status\n      end\n    end\n  end\n\n  action(:dump) do\n    summary _(\"Outputs a dump of the internal template parse tree for debugging\")\n    arguments \"[--format <old|pn|json>] [--pretty] { -e <source> | [<templates> ...] } \"\n    returns _(\"A dump of the resulting AST model unless there are syntax or validation errors.\")\n    description <<-'EOT'\n      The dump action parses and validates the EPP syntax and dumps the resulting AST model\n      in a human readable (but not necessarily an easy to understand) format.\n\n      The output format can be controlled using the --format <old|pn|json> where:\n      * 'old' is the default, but now deprecated format which is not API.\n      * 'pn' is the Puppet Extended S-Expression Notation.\n      * 'json' outputs the same graph as 'pn' but with JSON syntax.\n\n      The output will be \"pretty printed\" when the option --pretty is given together with --format 'pn' or 'json'.","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/face/epp.rb#L83-L119","documentation":"Raised by `puppet epp validate` when every named template was found but at least one failed to parse or validate: `validate_template` printed the per-file error and returned false, `status &&= tmp` latched the failure, and because `missing_files` is empty the final `raise ... unless status` fires. The actionable detail (file, line, parse error) is in the Puppet.err output printed just before this summary error, not in the message itself.","triggerScenarios":"EPP files with unbalanced `<% if %>`/`<% end %>` tags, invalid Puppet expressions inside `<%= %>`, malformed parameter declaration blocks (`<%# parameters: ... -%>`); validating several files where one has a syntax error (the others still validate and report fine).","commonSituations":"Hand-editing templates without validating; upgrading Puppet versions where EPP parsing or parameter tags became stricter; ERB-to-EPP conversions done incompletely.","solutions":["Scroll up to the per-template error output — it names the file, line, and parse problem","Re-run `puppet epp dump <file>` to get parser diagnostics for the failing template","Fix the unbalanced/invalid tags and re-validate","Add `puppet epp validate` (or `puppet parser validate`) to CI for module templates"],"exampleFix":"# before (bad.epp)\n<% if $x { -%>value<% } %>    # invalid expression form\n# after\n<% if $x { -%>value<% } -%>\n# then\npuppet epp validate bad.epp","handlingStrategy":"validation","validationCode":"require 'puppet/pops/parser/evaluating_parser'\nparser = Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.new\nfiles.each do |f|\n  begin\n    parser.parse_string(File.read(f), f)\n  rescue Puppet::ParseError => e\n    abort \"#{f}: #{e.message}\"\n  end\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `puppet epp validate` in CI for every template change","Prefer `puppet epp dump` while iterating — it exposes parse errors directly","Match every `<% if %>`/`<% unless %>` with `<% end %>` before saving"],"tags":["epp","template","syntax-error","validation"],"backgroundTag":"template-validation-failed","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}