puppetlabs/puppet · error · MissingMetadata

The value for the key dependencies in the file metadata.json

Error message

The value for the key dependencies in the file metadata.json of the module #{name} must be an array, not: '#{value}'

What it means

In the same load_metadata pass, the `dependencies` value must be an Array; anything else (String, Hash) raises Puppet::Module::MissingMetadata with the offending value interpolated (lib/puppet/module.rb:257). Each array entry is then normalized: 'name' has dashes converted to slashes and a missing 'version_requirement' defaults to '>= 0.0.0'. Even a single dependency must be wrapped in an array.

Source

Thrown at lib/puppet/module.rb:257

    end
    {}
  end

  def load_metadata
    return if instance_variable_defined?(:@metadata)

    @metadata = data = read_metadata
    return if data.empty?

    @forge_name = data['name'].tr('-', '/') if data['name']

    [:source, :author, :version, :license, :dependencies].each do |attr|
      value = data[attr.to_s]
      raise MissingMetadata, "No #{attr} module metadata provided for #{name}" if value.nil?

      if attr == :dependencies
        unless value.is_a?(Array)
          raise MissingMetadata, "The value for the key dependencies in the file metadata.json of the module #{name} must be an array, not: '#{value}'"
        end

        value.each do |dep|
          name = dep['name']
          dep['name'] = name.tr('-', '/') unless name.nil?
          dep['version_requirement'] ||= '>= 0.0.0'
        end
      end

      send(attr.to_s + "=", value)
    end
  end

  # Return the list of manifests matching the given glob pattern,
  # defaulting to 'init.pp' for empty modules.
  def match_manifests(rest)
    if rest
      wanted_manifests = wanted_manifests_from(rest)

View on GitHub (pinned to e227c27540)

Solutions

  1. Rewrite dependencies as an array of objects: [{"name": "puppetlabs/stdlib", "version_requirement": ">= 9.0.0"}]
  2. version_requirement may be omitted (defaults to '>= 0.0.0'); name may use dash or slash form (dashes are normalized to slashes)
  3. Run `pdk validate` or metadata-json-lint before shipping the module

Example fix

// before (metadata.json)
"dependencies": "puppetlabs/stdlib"

// after
"dependencies": [
  {
    "name": "puppetlabs/stdlib",
    "version_requirement": ">= 9.0.0"
  }
]
Defensive patterns

Strategy: try-catch

Validate before calling

data = Puppet::Util::Json.load(File.read('metadata.json'))
raise ArgumentError, 'dependencies must be an Array' unless data['dependencies'].is_a?(Array)

Try / catch

begin
  mod = Puppet::Module.find(name, environment)
  mod.load_metadata if mod
rescue Puppet::Module::MissingMetadata => e
  Puppet.warning("module #{name}: #{e.message}")
  next
end

Prevention

When it happens

Trigger: "dependencies": "puppetlabs/stdlib" (a string); "dependencies": {"puppetlabs/stdlib": ">= 4.0.0"} (a mapping); metadata converted from older YAML-era dependency formats.

Common situations: Hand-authored metadata modeling one dependency as a scalar; mapping-style dependency lists; editors or generators autocompleting the wrong shape.

Related errors


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