jordansissel/fpm · error · FPM::InvalidPackageConfiguration

Unexpected CPAN 'author' field type: #{metadata["author"].cl

Error message

Unexpected CPAN 'author' field type: #{metadata["author"].class}. This is a bug.

What it means

When setting vendor from CPAN metadata, a case statement accepts only String, Array, or nil for the 'author' field; any other class (in practice a Hash from an unusual MYMETA.yml/META.json) falls into the else branch and raises FPM::InvalidPackageConfiguration marked 'This is a bug' — an unexpected metadata shape that fpm's parser does not model.

Source

Thrown at lib/fpm/package/cpan.rb:124

      dist_name, _, dist_version = metadata["release"].rpartition('-')
      logger.info("Setting package name from 'distribution'",
                  :distribution => dist_name)
      self.name = fix_name(dist_name)
      self.provides = search_provided_modules(dist_name, dist_version)
    else
      logger.info("Setting package name from 'name'",
                   :name => metadata["name"])
      self.name = fix_name(metadata["name"])
      self.provides << cap_name(metadata["name"]) + " = #{self.version}"
    end

    # author is not always set or it may be a string instead of an array
    self.vendor = case metadata["author"]
      when String; metadata["author"]
      when Array; metadata["author"].join(", ")
      when NilClass; "No Vendor Or Author Provided"
      else
        raise FPM::InvalidPackageConfiguration, "Unexpected CPAN 'author' field type: #{metadata["author"].class}. This is a bug."
    end if metadata.include?("author")

    self.url = metadata["resources"]["homepage"] rescue "unknown"

    # TODO(sissel): figure out if this perl module compiles anything
    # and set the architecture appropriately.
    self.architecture = "all"

    # Install any build/configure dependencies with cpanm.
    # We'll install to a temporary directory.
    logger.info("Installing any build or configure dependencies")

    if attributes[:cpan_sandbox_non_core?]
      cpanm_flags = ["-L", build_path("cpan"), moduledir]
    else
      cpanm_flags = ["-l", build_path("cpan"), moduledir]
    end

View on GitHub (pinned to b6d77ba72a)

Solutions

  1. Normalize the field in META.json/META.yml/MYMETA.yml so author is a string or an array of strings, then rebuild
  2. Delete stale MYMETA.* and regenerate with 'perl Makefile.PL' so well-formed metadata is produced
  3. If the metadata is standards-compliant yet rejected, report it on the fpm tracker — the message itself declares it a bug

Example fix

# before (MYMETA.yml)
author:
  name: Alice
  email: alice@example.com

# after
author:
  - Alice <alice@example.com>
Defensive patterns

Strategy: type-guard

Type guard

require 'yaml'

def sane_cpan_author?(path)
  meta = YAML.load_file(path)
  author = meta && meta['author']
  author.nil? || author.is_a?(String) || (author.is_a?(Array) && author.all? { |a| a.is_a?(String) })
end

abort 'author field in MYMETA.yml must be a string or list of strings' unless sane_cpan_author?('MYMETA.yml')

Try / catch

begin
  pkg = FPM::Package::Cpan.new
  pkg.input(module_dir)
rescue FPM::InvalidPackageConfiguration => e
  abort "malformed CPAN metadata (#{e.message}); normalize the author field in META/MYMETA"
end

Prevention

When it happens

Trigger: A hand-edited or tool-generated META/MYMETA file whose author is a mapping (author: {name: ..., email: ...}) instead of a string or list; YAML sources coercing the field into a non-standard type that then merges into the metadata.

Common situations: Developers hand-writing MYMETA.yml; internal metadata generators emitting structured author objects; older META samples pasted from other ecosystems.

Related errors


AI-assisted analysis of jordansissel/fpm@b6d77ba72a (2026-08-21). Data as JSON: /api/errors/45761596ebe9818f. Report an issue: GitHub.