{"record":{"id":"ef75575b08ed577b","repo":"puppetlabs/puppet","slug":"epp-syntax-checker-invalid-acceptor-got-klas","errorCode":null,"errorMessage":"EPP syntax checker: invalid Acceptor, got: '%{klass}'.","messagePattern":"EPP syntax checker: invalid Acceptor, got: '%(.+?)'\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/syntax_checkers/epp.rb","lineNumber":20,"sourceCode":"\n# A syntax checker for JSON.\n# @api public\nrequire_relative '../../puppet/syntax_checkers'\nclass Puppet::SyntaxCheckers::EPP < Puppet::Plugins::SyntaxCheckers::SyntaxChecker\n  # Checks the text for Puppet Language EPP syntax issues and reports them to the given acceptor.\n  #\n  # Error messages from the checker are capped at 100 chars from the source text.\n  #\n  # @param text [String] The text to check\n  # @param syntax [String] The syntax identifier in mime style (only accepts 'pp')\n  # @param acceptor [#accept] A Diagnostic acceptor\n  # @param source_pos [Puppet::Pops::Adapters::SourcePosAdapter] A source pos adapter with location information\n  # @api public\n  #\n  def check(text, syntax, acceptor, source_pos)\n    raise ArgumentError, _(\"EPP syntax checker: the text to check must be a String.\") unless text.is_a?(String)\n    raise ArgumentError, _(\"EPP syntax checker: the syntax identifier must be a String, e.g. pp\") unless syntax == 'epp'\n    raise ArgumentError, _(\"EPP syntax checker: invalid Acceptor, got: '%{klass}'.\") % { klass: acceptor.class.name } unless acceptor.is_a?(Puppet::Pops::Validation::Acceptor)\n\n    begin\n      Puppet::Pops::Parser::EvaluatingParser::EvaluatingEppParser.singleton.parse_string(text)\n    rescue => e\n      # Cap the message to 100 chars and replace newlines\n      msg = _(\"EPP syntax checker: \\\"%{message}\\\"\") % { message: e.message().slice(0, 500).gsub(/\\r?\\n/, \"\\\\n\") }\n\n      # TODO: improve the pops API to allow simpler diagnostic creation while still maintaining capabilities\n      # and the issue code. (In this case especially, where there is only a single error message being issued).\n      #\n      issue = Puppet::Pops::Issues.issue(:ILLEGAL_EPP) { msg }\n      acceptor.accept(Puppet::Pops::Validation::Diagnostic.new(:error, issue, source_pos.file, source_pos, {}))\n    end\n  end\nend\n","sourceCodeStart":2,"sourceCodeEnd":36,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/syntax_checkers/epp.rb#L2-L36","documentation":"Puppet's pluggable syntax-checker API validates EPP template text. The check method in lib/puppet/syntax_checkers/epp.rb requires the third argument to be an instance of Puppet::Pops::Validation::Acceptor, the diagnostic collector that gathers errors and warnings. Passing any other object, even one that duck-types #accept, raises ArgumentError before any parsing happens. In normal operation (heredoc/template validation via Puppet::Pops::Evaluator::ExternalSyntaxSupport#assert_external_syntax) the runtime always constructs a real Acceptor, so this error signals direct API misuse.","triggerScenarios":"Calling Puppet::SyntaxCheckers::EPP.new.check(text, 'epp', acceptor, source_pos) with a custom collector object, an Array, a Proc, or a test double instead of a Puppet::Pops::Validation::Acceptor. Also hit when a custom checker registered under Puppet::Plugins::SyntaxCheckers::SYNTAX_CHECKERS_KEY forwards its acceptor argument incorrectly.","commonSituations":"Writing RSpec tests around the checker API, building custom lint/CI tooling that wraps Puppet's EPP validation, or refactoring code that previously passed a hand-rolled acceptor that happened to work against an older Puppet version.","solutions":["Construct the acceptor exactly as the evaluator does: acceptor = Puppet::Pops::Validation::Acceptor.new, pass it to check, then read acceptor.diagnostics","If you need custom reporting, keep the real Acceptor and inspect its diagnostics after the call instead of substituting your own collector class","For a genuinely custom pipeline, wrap rather than replace: call the checker with a real Acceptor and post-process acceptor.diagnostics"],"exampleFix":"# before\nchecker = Puppet::SyntaxCheckers::EPP.new\nchecker.check(text, 'epp', MyCollector.new, source_pos) # => ArgumentError\n\n# after\nchecker = Puppet::SyntaxCheckers::EPP.new\nacceptor = Puppet::Pops::Validation::Acceptor.new\nchecker.check(text, 'epp', acceptor, source_pos)\nacceptor.diagnostics.each { |d| puts d.message }","handlingStrategy":"type-guard","validationCode":"raise ArgumentError, \"acceptor must be an Acceptor, got #{acceptor.class}\" unless acceptor.is_a?(Puppet::Pops::Validation::Acceptor)","typeGuard":"def valid_acceptor?(a)\n  a.is_a?(Puppet::Pops::Validation::Acceptor)\nend","tryCatchPattern":"begin\n  checker.check(text, 'epp', acceptor, pos)\nrescue ArgumentError => e\n  raise ConfigError, \"EPP checker API misused: #{e.message}\"\nend","preventionTips":["Always construct the acceptor in one place: acceptor = Puppet::Pops::Validation::Acceptor.new","Never substitute a duck-typed collector; read acceptor.diagnostics after the call instead","In specs, use the real Acceptor class rather than doubles"],"tags":["puppet","epp","syntax-checker","argumenterror","api-misuse"],"backgroundTag":"invalid-argument-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}