Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-11629

Puppet::Util::Json raises when reading an empty file

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 7.20.0
    • None
    • Bug Fix
    • Puppet no longer errors when loading an empty task metadata file.
    • Needs Assessment

    Description

      See details in PE-34535, a portion of the stack trace is below:

      2022-09-08T15:05:11.285-04:00 ERROR [qtp2123677471-318634] [p.r.core] Internal Server Error: org.jruby.exceptions.RuntimeError: (InvalidMetadata) JSON::ParserError
          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)
          at opt.puppetlabs.puppet.lib.ruby.vendor_ruby.puppet.module.task.metadata(/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/module/task.rb:244)
          at opt.puppetlabs.puppet.lib.ruby.vendor_ruby.puppet.info_service.task_information_service.tasks_per_environment(/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/info_service/task_information_service.rb:9)
      

      Puppet uses multi-json to wrap different json implementations. This way you can get better performance when using puppet as a library in different runtimes, e.g. Oj, JrJackson, etc.

      When MultiJson.load is called it is supposed to according to the doc:

      When loading invalid JSON, MultiJSON will throw a MultiJson::ParseError

      However, when using the default json backend, it raises a JSON namespaced exception instead when trying to parse an empty string. This confuses Puppet::Util::Json.load and causes the JSON exception to leak.

      This seems like a bug in multijson, but we should be more defensive when rescuing so.

      Attachments

        Issue Links

          Activity

            People

              michael.hashizume Michael Hashizume
              josh Josh Cooper
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support