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

Util::JSON.dump receives non-hash options

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.25.0, PUP 7.12.0
    • None
    • Skeletor
    • 2
    • Skeletor - 09/22/2021
    • Needs Assessment
    • Bug Fix
    • Puppet's /puppet/v3/file_metadatas REST API would fail if the multi_json gem was uninstalled or when running puppetserver from source.
    • Needs Assessment

    Description

      Puppet Version: Main branch (401e01b2691d9c496749ff07f7fca7fc852e105c)
      Puppet Server Version: Main branch (38479aafcb6c27d826976e31a993258e9e9e4de2)
      OS Name/Version: Ubuntu 20.04

      While testing the file_metadatas Puppetserver endpoint, when sending this request:
      code
      https://localhost:8140/puppet/v3/file_metadatas/scripts/mymodule/script.sh?environment=production&recurse=yes
      code
      Puppet errors with (apologies for the backtrace!):
      code
      2021-09-03 07:58:27,688 DEBUG [qtp1541353205-57] [puppetserver] Puppet Could not render_multiple to Puppet::Network::Format[json]: undefined method `delete' for #<JSON::Ext::Generator::State:0x79067448>
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/util/json.rb:64:in `dump'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/format_support.rb:105:in `to_json'
      json/ext/GeneratorMethods.java:79:in `to_json'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/util/json.rb:65:in `dump'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/formats.rb:129:in `render_multiple'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/format_support.rb:26:in `render_multiple'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:161:in `block in do_search'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:192:in `block in first_response_formatter_for'
      org/jruby/RubyEnumerable.java:690:in `find'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:190:in `first_response_formatter_for'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:160:in `do_search'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:53:in `block in call'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/context.rb:62:in `override'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet.rb:306:in `override'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/indirected_routes.rb:52:in `call'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/api/server/v3.rb:17:in `block in wrap'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/route.rb:82:in `block in process'
      org/jruby/RubyArray.java:1809:in `each'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/route.rb:81:in `process'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/route.rb:88:in `process'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/route.rb:88:in `process'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:86:in `block in process'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:69:in `block in with_request_profiling'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in `profile'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/util/profiler.rb:51:in `profile'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:65:in `with_request_profiling'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:85:in `block in process'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:92:in `respond_to_errors'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/network/http/handler.rb:84:in `process'
      uri:classloader:/puppetserver-lib/puppet/server/master.rb:69:in `block in handleRequest'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet/context.rb:62:in `override'
      /home/lucy/githubs/puppetserver/ruby/puppet/lib/puppet.rb:306:in `override'
      uri:classloader:/puppetserver-lib/puppet/server/master.rb:68:in `handleRequest'
      code

      This only happens when requesting the scripts mount - the request
      code
      https://localhost:8140/puppet/v3/file_metadatas/modules/mymodule/file?environment=production&recurse=yes
      code
      behaves as expected.

      The object that dump is receiving in this case actually can be converted to a hash, and adding
      code
      options = options.to_h unless options.is_a?(Hash)
      code
      fixes the issue, but doesn't really get to why this method is receiving the wrong object to begin with.

      Happy to provide more testing and info!

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              lucy Lucy Voigt
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support