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_hash

View on GitHub (pinned to e227c27540)

Solutions

  1. 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
  2. Rename MSDN-style members: wShowWindow -> sw_flags, dwFlags -> startf_flags, dwX -> x
  3. 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

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


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/2895783f2cd7e579. Report an issue: GitHub.