{"record":{"id":"b6c9ea0fa36c1764","repo":"puppetlabs/puppet","slug":"invalid-key-key","errorCode":null,"errorMessage":"invalid key '#{key}'","messagePattern":"invalid key '#(.+?)'","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/util/windows/monkey_patches/process.rb","lineNumber":222,"sourceCode":"\n    def initialize_defaults\n      @hash = {\n        app_name: nil,\n        creation_flags: 0,\n        close_handles: true\n      }\n      @si_hash = nil\n      @procinfo = nil\n    end\n\n    def validate_args(args)\n      raise TypeError, 'hash keyword arguments expected' unless args.is_a?(Hash)\n    end\n\n    def validate_keys(args)\n      args.each do |key, val|\n        key = key.to_s.to_sym\n        raise ArgumentError, \"invalid key '#{key}'\" unless VALID_KEYS.include?(key)\n\n        hash[key] = val\n      end\n    end\n\n    def validate_startup_info\n      hash[:startup_info].each do |key, val|\n        key = key.to_s.to_sym\n        raise ArgumentError, \"invalid startup_info key '#{key}'\" unless VALID_SI_KEYS.include?(key)\n\n        si_hash[key] = val\n      end\n    end\n\n    def validate_command_line\n      raise ArgumentError, 'command_line or app_name must be specified' unless hash[:app_name] || hash[:command_line]\n    end\n","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/util/windows/monkey_patches/process.rb#L204-L240","documentation":"Process.create validates every top-level option key against VALID_KEYS (app_name, command_line, inherit, creation_flags, cwd, environment, startup_info, thread_inherit, process_inherit, close_handles, with_logon, domain, password) and raises ArgumentError('invalid key ...') for anything else. Keys are normalized with to_s.to_sym, so string keys are fine - the error fires only for names outside the whitelist.","triggerScenarios":"Passing typo'd or unsupported options like :commandline, :show_window (belongs in startup_info), :timeout, :env (should be :environment), or options from other process libraries (e.g. win32-process gem docs or POSIX spawn options like :unsetenv_others).","commonSituations":"Copy-pasting option hashes from win32-process examples or Stack Overflow that include keys this patched API dropped; renaming refactors (:cmd -> stale callers); merging user-supplied option hashes without filtering.","solutions":["Spell keys exactly as in the whitelist: app_name command_line inherit creation_flags cwd environment startup_info thread_inherit process_inherit close_handles with_logon domain password","Move console/GUI options (show_window etc.) into the startup_info sub-hash","Filter foreign option hashes before forwarding: opts.slice(*VALID_KEYS) style"],"exampleFix":"// before\nProcess.create(commandline: 'dir', env: 'A=1')  # both keys invalid\n\n// after\nProcess.create(command_line: 'dir', environment: 'A=1')","handlingStrategy":"validation","validationCode":"VALID_KEYS = %i[app_name command_line inherit creation_flags cwd environment\n               startup_info thread_inherit process_inherit close_handles with_logon\n               domain password].freeze\nunknown = args.keys.map { |k| k.to_s.to_sym } - VALID_KEYS\nraise ArgumentError, \"unknown Process.create keys: #{unknown.join(', ')}\" unless unknown.empty?","typeGuard":null,"tryCatchPattern":"begin\n  info = Process.create(args)\nrescue ArgumentError => e\n  raise unless e.message =~ /invalid key/\n  raise \"check spelling against VALID_KEYS: #{e.message}\"\nend","preventionTips":["Keep the option whitelist next to every Process.create call site","Filter external option hashes down to known keys before forwarding","Remember :environment (not :env) and :command_line (not :commandline)"],"tags":["windows","process","argumenterror","option-validation","puppet"],"backgroundTag":"invalid-configuration-key","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}