puppetlabs/puppet · error · ArgumentError

urn.inspect

Error message

urn.inspect

What it means

Raised by `repo_tag_from_urn` (lib/puppet/provider/package/pkgng.rb:98) in the FreeBSD/DragonFly pkgng provider. A `source` with a `urn:` scheme is expected to name a repository as `urn:freebsd:repo:<tag>` so install can run `pkg install -r <tag>`; the strict regex `^urn:freebsd:repo:(.+)$` rejecting anything else raises ArgumentError with the urn inspected.

Source

Thrown at lib/puppet/provider/package/pkgng.rb:98

    rescue Puppet::ExecutionFailure
      []
    end
  end

  def self.prefetch(resources)
    packages = instances
    resources.each_key do |name|
      provider = packages.find { |p| p.name == name or p.origin == name }
      if provider
        resources[name].provider = provider
      end
    end
  end

  def repo_tag_from_urn(urn)
    # extract repo tag from URN: urn:freebsd:repo:<tag>
    match = /^urn:freebsd:repo:(.+)$/.match(urn)
    raise ArgumentError urn.inspect unless match

    match[1]
  end

  def install
    source = resource[:source]
    source = URI(source) unless source.nil?

    # Ensure we handle the version
    case resource[:ensure]
    when true, false, Symbol
      installname = resource[:name]
    else
      # If resource[:name] is actually an origin (e.g. 'www/curl' instead of
      # just 'curl'), drop the category prefix. pkgng doesn't support version
      # pinning with the origin syntax (pkg install curl-1.2.3 is valid, but
      # pkg install www/curl-1.2.3 is not).
      if resource[:name] =~ %r{/}

View on GitHub (pinned to e227c27540)

Solutions

  1. Use exactly `urn:freebsd:repo:<tag>` where <tag> is the repository name from /etc/pkg/*.conf or `pkg -vv`.
  2. Double-check the scheme and namespace spelling (freebsd, singular repo).
  3. If you meant a direct package URL, drop the urn and pass the http(s) URL as source instead.

Example fix

# before
package { 'curl':
  ensure   => installed,
  provider => pkgng,
  source   => 'urn:freebsd:repositories:latest',
}

# after
package { 'curl':
  ensure   => installed,
  provider => pkgng,
  source   => 'urn:freebsd:repo:latest',
}
Defensive patterns

Strategy: validation

Validate before calling

# Validate the urn shape before the agent applies it
source='urn:freebsd:repo:latest'
echo "$source" | grep -Eq '^urn:freebsd:repo:.+$' || echo "invalid repo urn - use urn:freebsd:repo:<tag>"

Type guard

# Ruby narrowing predicate for repo urns
def freebsd_repo_urn?(str)
  str.is_a?(String) && str.match?(%r{\Aurn:freebsd:repo:(.+)\z})
end

Try / catch

begin
  tag = repo_tag_from_urn(source.to_s)
rescue ArgumentError
  raise ArgumentError, "source must be urn:freebsd:repo:<tag>, got #{source}"
end

Prevention

When it happens

Trigger: `source => 'urn:freebsd:repo:latest'` works; failing values include `urn:freebsd:repo:` (empty tag), `urn:freebsd:repositories:latest`, `urn:freebsd:repo` (no tag part), or any other urn grammar. Note that http/ftp/other-scheme sources take the `pkg add <url>` path and never hit this check.

Common situations: Typos in the urn string; assuming a different urn namespace; copying a tag name that does not matter here - the failure is purely about the urn's shape, not whether the repo exists.

Related errors


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