{"record":{"id":"2f52918ecbe8cebf","repo":"puppetlabs/puppet","slug":"manifest-file-or-code-string-cannot-be-given-when","errorCode":null,"errorMessage":"manifest_file or code_string cannot be given when configured_by_env is true","messagePattern":"manifest_file or code_string cannot be given when configured_by_env is true","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/pal/pal_impl.rb","lineNumber":77,"sourceCode":"  def self.with_script_compiler(\n    configured_by_env: false,\n    manifest_file:     nil,\n    code_string:       nil,\n    facts:             {},\n    variables:         {},\n    set_local_facts:   true,\n    &block\n  )\n    # TRANSLATORS: do not translate variable name strings in these assertions\n    assert_mutually_exclusive(manifest_file, code_string, 'manifest_file', 'code_string')\n    assert_non_empty_string(manifest_file, 'manifest_file', true)\n    assert_non_empty_string(code_string, 'code_string', true)\n    assert_type(T_BOOLEAN, configured_by_env, \"configured_by_env\", false)\n\n    if configured_by_env\n      unless manifest_file.nil? && code_string.nil?\n        # TRANSLATORS: do not translate the variable names in this error message\n        raise ArgumentError, _(\"manifest_file or code_string cannot be given when configured_by_env is true\")\n      end\n\n      # Use the manifest setting\n      manifest_file = Puppet[:manifest]\n    elsif manifest_file.nil? && code_string.nil?\n      # An \"undef\" code_string is the only way to override Puppet[:manifest] & Puppet[:code] settings since an\n      # empty string is taken as Puppet[:code] not being set.\n      #\n      code_string = 'undef'\n    end\n\n    previous_tasks_value = Puppet[:tasks]\n    previous_code_value = Puppet[:code]\n    Puppet[:tasks] = true\n    # After the assertions, if code_string is non nil - it has the highest precedence\n    Puppet[:code] = code_string unless code_string.nil?\n\n    # If manifest_file is nil, the #main method will use the env configured manifest","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/pal/pal_impl.rb#L59-L95","documentation":"PAL environment setup raises ArgumentError when configured_by_env: true is combined with manifest_file or code_string. configured_by_env means 'take the code from Puppet settings' (it then uses Puppet[:manifest]), so an inline manifest or code string is a conflicting input.","triggerScenarios":"Puppet::Pal.with_script_compiler(manifest_file: 'site.pp', configured_by_env: true), or any PAL entry call passing both code_string and configured_by_env: true.","commonSituations":"Wrappers that always forward a code_string option into PAL while defaulting configured_by_env to true; migrating older PAL code that tolerated the combination; scripts that want Puppet[:code] but also pass a string.","solutions":["Drop configured_by_env (default false) when you pass manifest_file or code_string","Or keep configured_by_env: true and omit manifest_file/code_string, setting Puppet[:manifest]/Puppet[:code] instead","Audit wrapper code so the two options cannot both reach PAL"],"exampleFix":"# before\nPuppet::Pal.with_script_compiler(code_string: code, configured_by_env: true) { |c| }\n\n# after\nPuppet::Pal.with_script_compiler(code_string: code) { |c| }","handlingStrategy":"validation","validationCode":"if configured_by_env && (manifest_file || code_string)\n  raise ArgumentError, 'cannot combine configured_by_env with manifest_file/code_string'\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Decide one code source per call site: settings (configured_by_env) or explicit code/manifest","Do not default configured_by_env to true in wrappers that also accept code_string"],"tags":["puppet","pal","configuration","argument-error"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}