{"record":{"id":"93709df077c565bf","repo":"puppetlabs/puppet","slug":"callee-expects-a-value-for-parameter-to","errorCode":null,"errorMessage":"%{callee}: expects a value for parameter $%{to}","messagePattern":"%(.+?): expects a value for parameter \\$%(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/parser/scope.rb","lineNumber":212,"sourceCode":"        end\n        parameter_reference_failure(name, bad)\n      end\n    end\n\n    def evaluate(name, expression, scope, evaluator)\n      scope.with_guarded_scope do\n        bad = catch(:unevaluated_parameter) do\n          scope.new_match_scope(nil)\n          return as_read_only { evaluator.evaluate(expression, scope) }\n        end\n        parameter_reference_failure(name, bad)\n      end\n    end\n\n    def parameter_reference_failure(from, to)\n      # Parameters are evaluated in the order they have in the @params hash.\n      keys = @params.keys\n      raise Puppet::Error, _(\"%{callee}: expects a value for parameter $%{to}\") % { callee: @callee_name, to: to } if keys.index(to) < keys.index(from)\n\n      raise Puppet::Error, _(\"%{callee}: default expression for $%{from} tries to illegally access not yet evaluated $%{to}\") % { callee: @callee_name, from: from, to: to }\n    end\n    private :parameter_reference_failure\n\n    def initialize(parent, callee_name, param_names)\n      super(parent)\n      @callee_name = callee_name\n      @params = {}\n      param_names.each { |name| @params[name] = Access.new }\n    end\n\n    def [](name)\n      access = @params[name]\n      return super if access.nil?\n\n      throw(:unevaluated_parameter, name) unless access.assigned?\n      access.value","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/parser/scope.rb#L194-L230","documentation":"Raised by Puppet::Parser::Scope::ParameterScope#parameter_reference_failure while a class/define parameter default is being evaluated. Parameters are evaluated strictly in declaration order; if the default expression of parameter $from reads parameter $to, and $to is declared EARLIER (keys.index(to) < keys.index(from)) but still unassigned, Puppet knows $to can never receive a value from this evaluation, so the callee is simply missing a required argument. The message names the callee (class/define/lambda) and the parameter that never got a value.","triggerScenarios":"Declaring `class example($b, $a = $b) {}` and including it without a value for $b (e.g. bare `include example`). When $a's default reads $b, ParameterScope#[] throws :unevaluated_parameter because $b's Access was never assigned; since $b precedes $a, evaluate() raises 'example: expects a value for parameter $b'. Same for defines: `define d($b, $a = $b)` used as `d { 'x': }`.","commonSituations":"Refactoring a class so a previously-defaulted parameter loses its default while another parameter still references it; copying a define signature and forgetting to pass all required parameters at call sites; relying on Hiera automatic parameter lookup silently failing because no matching key exists for the referenced parameter.","solutions":["Pass an explicit value for the named parameter at the declaration site: `class { 'example': b => 10 }` (include cannot pass parameters).","Give the referenced parameter a default so it is always assigned: `class example($b = 5, $a = $b)`.","Add a matching Hiera key (e.g. 'example::b' in the environment data) so automatic parameter lookup supplies the value.","Restructure so the referencing default does not depend on a defaulted-or-missing earlier parameter (compute both from a shared expression or a custom function)."],"exampleFix":"# before\n# site.pp\ninclude example            # error: example: expects a value for parameter $b\n# class example($b, $a = $b) { }\n\n# after\nclass { 'example':\n  b => 10,\n}","handlingStrategy":"validation","validationCode":"# site.pp — always pass required params explicitly instead of bare include\n# lint: check classes whose param defaults reference other params\n# rough static check of a manifest's parameter list:\n# puppet parser validate catches syntax only; use catalog preview:\n#   puppet apply --noop --execute \"include example\" \n# fails fast with the parameter name before production runs.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never rely on a later parameter's default to feed an earlier required parameter — either default it or always pass it.","Prefer class-resource declarations (`class { 'x': param => v }`) over `include` in code paths where parameters matter.","Keep Hiera keys aligned with every class parameter that lacks a default (example::b style).","Add a smoke-test profile in CI that compiles representative nodes to catch missing-parameter errors before deploy."],"tags":["puppet","dsl","parameters","class-declaration"],"backgroundTag":"missing-required-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}