When selecting a task to run in the console, you might get an Internal Server Error: org.jruby.exceptions.RuntimeError: (InvalidMetadata) JSON::ParserError
error at the top of the page.
Error messages and logs
Internal Server Error: org.jruby.exceptions.RuntimeError: (InvalidMetadata) JSON::ParserError` error
at opt.puppetlabs.puppet.lib.ruby.vendor_ruby.puppet.module.task.read_metadata(/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/module/task.rb:240)
”
You get this error when there are JSON files in the module or module environment which cause services to fail when they are parsed.
Version and installation information
PE version: All supported
Solution
To resolve the error, use a linter to fix JSON metadata syntax issues associated with the affected module tasks. If you have a preferred JSON linting tool, you can use that. You can also use the following steps to install jsonlint
, a gem-based JSON linting tool, using either Puppet Development Kit (PDK) or the version of Ruby included in Puppet Enterprise (PE). If you set up PDK, you can also test your code and avoid future issues with module code.
Note: We can’t provide support for third-party software.
Install and use jsonlint
using PDK
Complete the following steps to install jsonlint
in PDK on a Puppet Enterprise node that has internet access and a copy of the module’s code on it.
Before you begin:
-
The module you want to lint must be converted to a standardized PDK module.
To install the jsonlint
gem, run the following commands:
-
Add
jsonlint
toGemfile.local
by runningecho 'gem "jsonlint"' >> Gemfile.local
-
Add dependencies for
jsonlint
by runningpdk bundle install
-
Lint JSON files in the code development environment by running
pdk bundle exec jsonlint **/*.json
-
Check the output and resolve any errors that you find. Learn how to fix some common JSON errors.
After you fix the issues, redeploy your code.
Install and use jsonlint
using the Ruby included with PE
To install jsonlint
using the Ruby included with PE, complete the following steps on a node with the module’s code on it, PE installed, and online access.
Before you begin, make sure that you have the RubyGems gem installed on the node.
-
Install the
jsonlint
gem by runninggem install jsonlint
-
Add the gem to Ruby by running
rehash
-
Lint JSON files in the Puppet Enterprise code development environment by running
jsonlint/etc/puppetlabs/code/environments/dev/**/*.json
Note: You can use a different path using
jsonlint/<PATH YOU WANT TO LINT>/**/*.json
-
Check the output and resolve any JSON syntax issues that you find. Learn how to fix some common JSON errors.
After you fix the issues, redeploy your code.
Help with JSON errors
-
Empty JSON files are not valid JSON
- Puppet Enterprise (PE) 2021.7.0 uses stricter JSON parsing than older versions do, so you might experience this error after an upgrade. JSON parsing returns null when the JSON string is empty. To fix the error, remove empty JSON metadata files to fix the error. -
expected hash key, not a hash close
- a { “key”: “value” } pair might be missing a colon.
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles