puppetlabs/puppet · error · ArgumentError

Could not parse filename to obtain the username, module name

Error message

Could not parse filename to obtain the username, module name and version.  (%{release_name})

What it means

Application#parse_filename raises ArgumentError when a release tarball basename (minus .tar.gz) does not match /^((.*?)-(.*?))-(\d+\.\d+\.\d+.*?)$/, the 'author-shortname-x.y.z...' shape used by Forge packages. The unpack/install pipeline relies on this to extract module name, author, and version, so a differently named archive is rejected before extraction.

Source

Thrown at lib/puppet/module_tool/applications/application.rb:80

        if File.file?(File.join(@path, 'Modulefile'))
          Puppet.warning _("A Modulefile was found in the root directory of the module. This file will be ignored and can safely be removed.")
        end

        @metadata
      end

      def load_metadata!
        @metadata = nil
        metadata(true)
      end

      def parse_filename(filename)
        match = /^((.*?)-(.*?))-(\d+\.\d+\.\d+.*?)$/.match(File.basename(filename, '.tar.gz'))
        if match
          module_name, author, shortname, version = match.captures
        else
          raise ArgumentError, _("Could not parse filename to obtain the username, module name and version.  (%{release_name})") % { release_name: @release_name }
        end

        unless SemanticPuppet::Version.valid?(version)
          raise ArgumentError, _("Invalid version format: %{version} (Semantic Versions are acceptable: http://semver.org)") % { version: version }
        end

        {
          :module_name => module_name,
          :author => author,
          :dir_name => shortname,
          :version => version
        }
      end
    end
  end
end

View on GitHub (pinned to e227c27540)

Solutions

  1. Rename the tarball to the canonical 'author-modulename-x.y.z-optional.tar.gz' form, e.g. 'puppetlabs-stdlib-9.0.0.tar.gz'.
  2. Re-download the package from the Forge so the original filename is preserved.
  3. If you built the package yourself, use `puppet module build` which names the pkg/ artifact correctly.

Example fix

# before
puppet module install ./stdlib-9.0.0.tar.gz   # missing author segment

# after
puppet module install ./puppetlabs-stdlib-9.0.0.tar.gz
Defensive patterns

Strategy: validation

Validate before calling

RELEASE_NAME = /\A(.+)-(\d+\.\d+\.\d+.*)\z/

basename = File.basename(tarball, '.tar.gz')
abort "rename to author-modulename-x.y.z.tar.gz" unless RELEASE_NAME.match?(basename)

Type guard

def release_tarball?(filename)
  File.basename(filename.to_s, '.tar.gz').match?(\A.+\-\d+\.\d+\.\d+.*\z) ? true : false
end

Try / catch

begin
  app.parse_filename(tarball)
rescue ArgumentError => e
  abort "tarball name must be author-modulename-x.y.z.tar.gz" if e.message.include?('Could not parse filename')
  raise
end

Prevention

When it happens

Trigger: Passing a tarball like 'stdlib.tar.gz' (no author/version), 'puppetlabs-stdlib.tar.gz' (no version), 'mymodule-1.2.tar.gz' (two-part version), or a renamed download such as 'stdlib (1).tar.gz' to an application that parses release filenames (e.g. installing from a local file whose name was edited).

Common situations: Browser-appended ' (1)' duplication suffixes on re-downloads; manual repackaging with a custom name; internal mirrors renaming artifacts; scripts dropping the author prefix when saving.

Related errors


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