puppetlabs/puppet · error · ArgumentError
Cannot use '%{a_term}' and '%{b_term}' at the same time
Error message
Cannot use '%{a_term}' and '%{b_term}' at the same time What it means
PAL's assert_mutually_exclusive raises ArgumentError when both of a forbidden pair are truthy. It guards the (manifest_file, code_string) pair and the (env_dir, envpath) pair on the PAL entry points - only one of each pair may be supplied.
Source
Thrown at lib/puppet/pal/pal_impl.rb:573
Puppet::Pops::Types::TypeFactory.pattern(/\A[a-z][a-z0-9_]*\z/), Puppet::Pops::Types::TypeFactory.data
)
def self.assert_type(type, value, what, allow_nil = false)
Puppet::Pops::Types::TypeAsserter.assert_instance_of(nil, type, value, allow_nil) { _('Puppet Pal: %{what}') % { what: what } }
end
def self.assert_non_empty_string(s, what, allow_nil = false)
assert_type(T_STRING, s, what, allow_nil)
end
def self.assert_optionally_empty_array(a, what, allow_nil = false)
assert_type(T_STRING_ARRAY, a, what, allow_nil)
end
private_class_method :assert_optionally_empty_array
def self.assert_mutually_exclusive(a, b, a_term, b_term)
if a && b
raise ArgumentError, _("Cannot use '%{a_term}' and '%{b_term}' at the same time") % { a_term: a_term, b_term: b_term }
end
end
private_class_method :assert_mutually_exclusive
def self.assert_block_given(block)
if block.nil?
raise ArgumentError, _("A block must be given")
end
end
private_class_method :assert_block_given
end
end
View on GitHub (pinned to e227c27540)
Solutions
- Supply only one of each pair (manifest_file or code_string; env_dir or envpath)
- In wrappers, apply precedence before delegating: manifest_file = nil if code_string
- Raise your own descriptive error early when the caller sets both
Example fix
# before
Puppet::Pal.in_environment('prod', env_dir: d, envpath: p) { |c| }
# after
Puppet::Pal.in_environment('prod', env_dir: d) { |c| } Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, 'pass env_dir OR envpath, not both' if env_dir && envpath
Prevention
- Apply explicit precedence in wrappers (e.g. env_dir wins, envpath nulled) instead of forwarding both
- Document each PAL option pair as mutually exclusive in your tool's help text
When it happens
Trigger: Passing manifest_file AND code_string to a PAL compiler call; passing env_dir AND envpath to in_environment.
Common situations: Wrapper APIs forwarding user options straight into PAL so both get set from config files; option precedence never decided upstream.
Related errors
- Given data_type value is not a data type, got '%{type}'
- manifest_file or code_string cannot be given when configured
- Given variables must be a hash, got %{type}
- puppet.tasks/unparseable-metadata
- The ssl_context and include_system_store parameters are mutu
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/98f250ecf0a8a9b2.
Report an issue: GitHub.