puppetlabs/puppet · error · ArgumentError

Unknown format %{resource_name}: %{full_flags}[%{bad_flag}]

Error message

Unknown format %{resource_name}: %{full_flags}[%{bad_flag}]

What it means

pkg.rb:55 (ifo_flag): while parsing `pkg list` style output, the provider maps the two-character flags column: position 0 must be 'i' (installed) or '-' (known), position 1 must be 'f' (hold/variant frozen) or '-'. Any other character raises ArgumentError 'Unknown format ...' with the offending flag, deliberately refusing to guess (as the comment says, avoid doing damage with output the parser does not understand).

Source

Thrown at lib/puppet/provider/package/pkg.rb:55

  def self.instances
    pkg(:list, '-Hv').split("\n").map { |l| new(parse_line(l)) }
  end

  # The IFO flag field is just what it names, the first field can have either
  # i_nstalled or -, and second field f_rozen or -, and last
  # o_bsolate or r_rename or -
  # so this checks if the installed field is present, and also verifies that
  # if not the field is -, else we don't know what we are doing and exit with
  # out doing more damage.
  def self.ifo_flag(flags)
    (
      case flags[0..0]
      when 'i'
        { :status => 'installed' }
      when '-'
        { :status => 'known' }
      else
        raise ArgumentError, _('Unknown format %{resource_name}: %{full_flags}[%{bad_flag}]') %
            { resource_name: name, full_flags: flags, bad_flag: flags[0..0] }
      end
    ).merge(
      case flags[1..1]
      when 'f'
        { :mark => :hold }
      when '-'
        {}
      else
        raise ArgumentError, _('Unknown format %{resource_name}: %{full_flags}[%{bad_flag}]') %
            { resource_name: name, full_flags: flags, bad_flag: flags[1..1] }
      end
    )
  end

  # The UFOXI field is the field present in the older pkg
  # (solaris 2009.06 - snv151a)
  # similar to IFO, UFOXI is also an either letter or -

View on GitHub (pinned to e227c27540)

Solutions

  1. Check the actual flags column: `pkg list -H --no_headers` style output; identify the unknown character (v/o/r on newer pkg).
  2. Upgrade the puppet agent to a release whose pkg provider understands the new flags (this parser was extended in later Puppet versions).
  3. As a stopgap, avoid the pkg provider for enumeration (don't run `puppet resource package`) and manage only explicitly named packages, or hold the pkg version until puppet is upgraded.
Defensive patterns

Strategy: try-catch

Validate before calling

# only feed well-formed flags to the provider path
flags = line.split[1] # e.g. 'if'
raise "unparseable pkg flags #{flags}" unless flags =~ /^[i-][f-]$/

Type guard

def known_pkg_flags?(flags)
  flags.is_a?(String) && flags.length == 2 && flags[0] =~ /[i-]/ && flags[1] =~ /[f-]/
end

Try / catch

begin
  Puppet::Type.type(:package).provider(:pkg).instances
rescue ArgumentError => e
  raise unless e.message =~ /Unknown format/
  # newer pkg emits unknown flags: skip enumeration rather than corrupting state
  Puppet.err("pkg flag parse failed: #{e.message}"); []
end

Prevention

When it happens

Trigger: Enumerating or prefetching packages with the pkg provider (Solaris 11/OpenIndiana/omnios) when pkg emits a flags character this Puppet version does not know — newer pkg(5) versions added flag meanings (e.g. 'v' variant-frozen, 'o' obsolete, 'r' renamed) that older Puppet's parser rejects.

Common situations: Older Puppet agent on a newer Solaris 11 SR/illumos distro after pkg was updated; `puppet resource package` or a catalog with any pkg-managed package triggering instances/prefetch on those hosts.

Related errors


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