puppetlabs/puppet · error · ArgumentError
invalid startup_info key '#{key}'
Error message
invalid startup_info key '#{key}' What it means
Inside Process.create, the :startup_info sub-hash is validated against VALID_SI_KEYS (startf_flags, desktop, title, x, y, x_size, y_count_chars-family sizes, fill_attribute, sw_flags, stdin, stdout, stderr) and any other key raises ArgumentError('invalid startup_info key ...'). These keys map one-to-one onto members of the Win32 STARTUPINFO struct that CreateProcess receives.
Source
Thrown at lib/puppet/util/windows/monkey_patches/process.rb:231
end
def validate_args(args)
raise TypeError, 'hash keyword arguments expected' unless args.is_a?(Hash)
end
def validate_keys(args)
args.each do |key, val|
key = key.to_s.to_sym
raise ArgumentError, "invalid key '#{key}'" unless VALID_KEYS.include?(key)
hash[key] = val
end
end
def validate_startup_info
hash[:startup_info].each do |key, val|
key = key.to_s.to_sym
raise ArgumentError, "invalid startup_info key '#{key}'" unless VALID_SI_KEYS.include?(key)
si_hash[key] = val
end
end
def validate_command_line
raise ArgumentError, 'command_line or app_name must be specified' unless hash[:app_name] || hash[:command_line]
end
def procinfo
@procinfo ||= PROCESS_INFORMATION.new
end
def hash
@hash ||= {}
end
def si_hashView on GitHub (pinned to e227c27540)
Solutions
- Use only the accepted startup_info keys: startf_flags desktop title x y x_size y_size x_count_chars y_count_chars fill_attribute sw_flags stdin stdout stderr
- Rename MSDN-style members: wShowWindow -> sw_flags, dwFlags -> startf_flags, dwX -> x
- Give startup_info only console/GUI concerns; everything else stays at the top level of the create hash
Example fix
// before
Process.create(command_line: 'dir', startup_info: { show_window: false }) # invalid key
// after
Process.create(command_line: 'dir', startup_info: { sw_flags: Process::SW_HIDE }) Defensive patterns
Strategy: validation
Validate before calling
VALID_SI_KEYS = %i[startf_flags desktop title x y x_size y_size x_count_chars
y_count_chars fill_attribute sw_flags stdin stdout stderr].freeze
unknown = args.fetch(:startup_info, {}).keys.map { |k| k.to_s.to_sym } - VALID_SI_KEYS
raise ArgumentError, "unknown startup_info keys: #{unknown.join(', ')}" unless unknown.empty? Try / catch
begin
info = Process.create(args)
rescue ArgumentError => e
raise unless e.message =~ /invalid startup_info key/
raise "startup_info accepts only STARTUPINFO members: #{e.message}"
end Prevention
- Map MSDN STARTUPINFO names to this API's names (wShowWindow -> sw_flags, dwFlags -> startf_flags)
- Keep console/GUI options inside startup_info and process options outside it
- Validate the sub-hash separately in wrappers that compose it from several sources
When it happens
Trigger: Putting options like :show_window (correct name is :sw_flags), :cwd, :creation_flags, or :hide inside startup_info; forwarding a raw STARTUPINFO-style hash from C-oriented docs (e.g. :wShowWindow, :dwFlags) instead of this API's ruby-ish names; typos like :std_out.
Common situations: Translating MSDN CreateProcess samples into Ruby; mixing top-level and startup_info options after refactors; version drift where a wrapper added convenience keys the patched validator never accepted.
Related errors
- invalid key '#{key}'
- command_line or app_name must be specified
- password must be specified if with_logon is used
- Invalid log level %{level}
- out_buffer is required
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/2895783f2cd7e579.
Report an issue: GitHub.