{"record":{"id":"a60ce10d43dc4d3f","repo":"puppetlabs/puppet","slug":"urn-inspect","errorCode":null,"errorMessage":"urn.inspect","messagePattern":"urn\\.inspect","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/pkgng.rb","lineNumber":98,"sourceCode":"    rescue Puppet::ExecutionFailure\n      []\n    end\n  end\n\n  def self.prefetch(resources)\n    packages = instances\n    resources.each_key do |name|\n      provider = packages.find { |p| p.name == name or p.origin == name }\n      if provider\n        resources[name].provider = provider\n      end\n    end\n  end\n\n  def repo_tag_from_urn(urn)\n    # extract repo tag from URN: urn:freebsd:repo:<tag>\n    match = /^urn:freebsd:repo:(.+)$/.match(urn)\n    raise ArgumentError urn.inspect unless match\n\n    match[1]\n  end\n\n  def install\n    source = resource[:source]\n    source = URI(source) unless source.nil?\n\n    # Ensure we handle the version\n    case resource[:ensure]\n    when true, false, Symbol\n      installname = resource[:name]\n    else\n      # If resource[:name] is actually an origin (e.g. 'www/curl' instead of\n      # just 'curl'), drop the category prefix. pkgng doesn't support version\n      # pinning with the origin syntax (pkg install curl-1.2.3 is valid, but\n      # pkg install www/curl-1.2.3 is not).\n      if resource[:name] =~ %r{/}","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/pkgng.rb#L80-L116","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Use exactly `urn:freebsd:repo:<tag>` where <tag> is the repository name from /etc/pkg/*.conf or `pkg -vv`.","Double-check the scheme and namespace spelling (freebsd, singular repo).","If you meant a direct package URL, drop the urn and pass the http(s) URL as source instead."],"exampleFix":"# before\npackage { 'curl':\n  ensure   => installed,\n  provider => pkgng,\n  source   => 'urn:freebsd:repositories:latest',\n}\n\n# after\npackage { 'curl':\n  ensure   => installed,\n  provider => pkgng,\n  source   => 'urn:freebsd:repo:latest',\n}","handlingStrategy":"validation","validationCode":"# Validate the urn shape before the agent applies it\nsource='urn:freebsd:repo:latest'\necho \"$source\" | grep -Eq '^urn:freebsd:repo:.+$' || echo \"invalid repo urn - use urn:freebsd:repo:<tag>\"","typeGuard":"# Ruby narrowing predicate for repo urns\ndef freebsd_repo_urn?(str)\n  str.is_a?(String) && str.match?(%r{\\Aurn:freebsd:repo:(.+)\\z})\nend","tryCatchPattern":"begin\n  tag = repo_tag_from_urn(source.to_s)\nrescue ArgumentError\n  raise ArgumentError, \"source must be urn:freebsd:repo:<tag>, got #{source}\"\nend","preventionTips":["Use exactly `urn:freebsd:repo:<tag>` with a tag from /etc/pkg/*.conf or `pkg -vv`.","Test urn strings with the regex in rspec-puppet tests for the profile.","Remember non-urn URLs are treated as `pkg add` targets, not repo selections."],"tags":["freebsd","pkgng","urn","repository","argument-error"],"backgroundTag":"invalid-urn-format","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}