{"record":{"id":"7f6f748579250f07","repo":"puppetlabs/puppet","slug":"name-has-an-invalid-and-unparsable-metadata-jso","errorCode":null,"errorMessage":"%{name} has an invalid and unparsable metadata.json file. The parse error: %{error}","messagePattern":"%(.+?) has an invalid and unparsable metadata\\.json file\\. The parse error: %(.+?)","errorType":"exception","errorClass":"FaultyMetadata","httpStatus":null,"severity":"error","filePath":"lib/puppet/module.rb","lineNumber":238,"sourceCode":"\n  def read_metadata\n    md_file = metadata_file\n    return {} if md_file.nil?\n\n    content = File.read(md_file, :encoding => 'utf-8')\n    content.empty? ? {} : Puppet::Util::Json.load(content)\n  rescue Errno::ENOENT\n    {}\n  rescue Puppet::Util::Json::ParseError => e\n    # TRANSLATORS 'metadata.json' is a specific file name and should not be translated.\n    msg = _(\"%{name} has an invalid and unparsable metadata.json file. The parse error: %{error}\") % { name: name, error: e.message }\n    case Puppet[:strict]\n    when :off\n      Puppet.debug(msg)\n    when :warning\n      Puppet.warning(msg)\n    when :error\n      raise FaultyMetadata, msg\n    end\n    {}\n  end\n\n  def load_metadata\n    return if instance_variable_defined?(:@metadata)\n\n    @metadata = data = read_metadata\n    return if data.empty?\n\n    @forge_name = data['name'].tr('-', '/') if data['name']\n\n    [:source, :author, :version, :license, :dependencies].each do |attr|\n      value = data[attr.to_s]\n      raise MissingMetadata, \"No #{attr} module metadata provided for #{name}\" if value.nil?\n\n      if attr == :dependencies\n        unless value.is_a?(Array)","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/module.rb#L220-L256","documentation":"Puppet::Module's metadata reader parses a module's metadata.json with Puppet::Util::Json and, on ParseError, reports 'invalid and unparsable metadata.json' with the underlying parser message (lib/puppet/module.rb:238). What happens next depends on the `strict` setting: :off logs to debug, :warning emits a warning, :error raises Puppet::Module::FaultyMetadata. The same broken file is therefore either noise or a hard failure purely by configuration.","triggerScenarios":"metadata.json with a trailing comma, comment, single-quoted strings, or BOM; a truncated file from an interrupted module install; running with `strict = error` in puppet.conf while any installed module has malformed metadata.","commonSituations":"Hand-edited metadata.json; modules generated by non-Puppet tooling; CI enforcing strict=error; files saved as UTF-16.","solutions":["Validate and repair the JSON: `ruby -rjson -e 'JSON.parse(File.read(\"metadata.json\"))'` or any JSON linter — the parser message in the error pinpoints the offset","Regenerate metadata.json with pdk or `puppet module generate`, which emits valid JSON","If third-party modules must be tolerated despite bad metadata, set `strict = warning` instead of :error — but fixing the file is the real remedy"],"exampleFix":"// before (metadata.json)\n{\n  \"name\": \"acme-web\",\n  \"version\": \"1.0.0\",\n  \"license\": \"Apache-2.0\",\n  \"dependencies\": [],\n}\n\n// after\n{\n  \"name\": \"acme-web\",\n  \"version\": \"1.0.0\",\n  \"license\": \"Apache-2.0\",\n  \"dependencies\": []\n}","handlingStrategy":"try-catch","validationCode":"def valid_module_metadata?(dir)\n  path = File.join(dir, 'metadata.json')\n  return true unless File.exist?(path)\n  Puppet::Util::Json.load(File.read(path))\n  true\nrescue Puppet::Util::Json::ParseError, Errno::ENOENT\n  false\nend","typeGuard":null,"tryCatchPattern":"begin\n  mod = Puppet::Module.find(name, environment)\n  mod.load_metadata if mod\nrescue Puppet::Module::FaultyMetadata => e\n  Puppet.warning(\"skipping module #{name}: #{e.message}\")\n  next\nend","preventionTips":["Lint metadata.json (pdk validate, metadata-json-lint) in CI before modules ship","Never hand-edit JSON casually — regenerate via pdk when possible","Know your `strict` mode: only strict=error turns bad metadata into FaultyMetadata exceptions"],"tags":["puppet","module","metadata","json","strict-mode"],"backgroundTag":"invalid-json-metadata","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}