[chef-dev] Re: error in json_compat when doing a cookbook upload


Chronological Thread 
  • From: Daniel DeLeo < >
  • To: Kishore S Kumar < >
  • Cc: chef-dev < >
  • Subject: [chef-dev] Re: error in json_compat when doing a cookbook upload
  • Date: Tue, 4 Dec 2012 18:57:37 -0800


On Tuesday, December 4, 2012 at 6:29 PM, Kishore S Kumar wrote:

Yes I was building master..!! However did the issue exist in previous releases and you did the same fix as this or was there a change in the way json parsing in done in 11.

On Dec 4, 2012 10:33 PM, "Daniel DeLeo" < "> > wrote:

We just recently removed all chef-server code from the Chef repository (and moved the remaining relevant code for chef-expander and chef-solr into separate repos). As part of this patch, we removed the Chef::Sandbox class. Unfortunately, Chef 10.x servers (and Opscode Hosted Chef) return JSON with a json_class of Chef::Sandbox from one of the API calls in cookbook upload.

So there's no change to how we parse JSON, it's just that we'd removed the class definition of Chef::Sandbox, not realizing it would be referenced when uploading cookbooks.

-- 
Daniel DeLeo
 

On Tuesday, December 4, 2012 at 3:21 AM, Kishore S Kumar wrote:

does anyone get this error while doing a `knife cookbook upload ..`

1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:43:in `rescue in block in deep_const_get': can't get const Chef::Sandbox: uninitialized constant Chef::Sandbox (ArgumentError)
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:40:in `block in deep_const_get'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `each'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `inject'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:35:in `deep_const_get'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/json_compat.rb:41:in `from_json'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:217:in `block in raw_http_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:317:in `retriable_rest_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:201:in `raw_http_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:195:in `api_request'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/rest.rb:162:in `put'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/cookbook_uploader.rb:99:in `upload_cookbooks'
from /Users/kishorek/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-11.0.0.alpha/lib/chef/knife/cookbook_upload.rb:230:in `upload'

making the following changes in rest.rb (line 217) fixed it.
if response['content-type'] =~ /json/
  Chef::JSONCompat.from_json(response_body.chomp, create_additions: false)
else

but I'm wondering if there is something else that I should be doing than this fix..

Looks like you're building from master? We recently fixed this, so try pulling and rebuilding the gem.

Chef unfortunately still relies on magical class inflation via json_class in quite a few places, so setting create_additions to false would break things elsewhere. We ended up fixing this particular issue by adding a dummy Sandbox class, which was the least ugly solution. Getting rid of json_class is something we'd like to do but just haven't had time for yet.

-- 
Daniel DeLeo





Archive powered by MHonArc 2.6.16.

§