Skip to content

Instantly share code, notes, and snippets.

@nmilford
Created June 3, 2013 14:13
Show Gist options
  • Save nmilford/5698431 to your computer and use it in GitHub Desktop.
Save nmilford/5698431 to your computer and use it in GitHub Desktop.
Chef run failures on Encoding::InvalidByteSequenceError: "\xC3" on US-ASCII
Encoding::InvalidByteSequenceError: "\xC3" on US-ASCII
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `encode'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:502:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/json_compat.rb:45:in `to_json'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/rest.rb:245:in `api_request'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/rest.rb:156:in `put_rest'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/node.rb:630:in `save'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.rb:210:in `save_updated_node'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.rb:422:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/client.rb:176:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/application.rb:140:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/application/client.rb:274:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/application/client.rb:267:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/application/client.rb:267:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/lib/chef/application.rb:72:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.18.2/bin/chef-client:26:in `<top (required)>'
/opt/chef/bin/chef-client:23:in `load'
/opt/chef/bin/chef-client:23:in `<main>
@nmilford
Copy link
Author

nmilford commented Jun 3, 2013

It is complaining about this bit of code on the result.to_json(*a)

    # Serialize this object as a hash
    def to_json(*a)
      result = {
        "name" => name,
        "chef_environment" => chef_environment,
        'json_class' => self.class.name,
        "automatic" => automatic_attrs,
        "normal" => normal_attrs,
        "chef_type" => "node",
        "default" => default_attrs,
        "override" => override_attrs,
        #Render correctly for run_list items so malformed json does not result
        "run_list" => run_list.run_list.map { |item| item.to_s }
      }
      result["_rev"] = couchdb_rev if couchdb_rev
      result.to_json(*a)
    end

I cannot locate the object that is causing the drama.

@UncleTallest
Copy link

Did you ever find a solution to this; I have come across this gist trying to trace down this error but there are only this gist and about 4 other pages showing up and none of them have a viable solution. One mentioned setting LC_TYPE and the other claimed that setting encoding to UTF-8 would solve it. Alas, neither does as advertised...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment