Skip to content

Instantly share code, notes, and snippets.

@stormsilver
Created October 28, 2009 21:50
Show Gist options
  • Save stormsilver/220888 to your computer and use it in GitHub Desktop.
Save stormsilver/220888 to your computer and use it in GitHub Desktop.
{
"foo": {
"bar": "baz\tquux"
}
}
1. Create a new node.
2. Edit the node and paste the following json into the node, replacing anything that's there.
3. Watch as it blows up. Applying btm's patch allows you to see the error:
Parser Error 500
574: unexpected token at '{"foo":{"bar":"baz quux"}}'
btm's patch:
http://github.com/btm/chef/commit/f29b3c0848c59cc1dc48f93003140179b0a79889
merb : worker (port 4000) ~ Started request handling: Wed Oct 28 16:51:40 -0500 2009
merb : worker (port 4000) ~ Routed to: {"name"=>"", "format"=>nil, "submit"=>"Create Node", "action"=>"create", "attributes"=>"{\"foo\":{\"bar\":\"baz\tquux\"}}", "controller"=>"chef_server_slice/nodes"}
merb : worker (port 4000) ~ Params: {"name"=>"", "format"=>nil, "submit"=>"Create Node", "action"=>"create", "attributes"=>"{\"foo\":{\"bar\":\"baz\tquux\"}}", "controller"=>"chef_server_slice/nodes"}
~ Exception creating node: 574: unexpected token at '{"foo":{"bar":"baz quux"}}'
merb : worker (port 4000) ~ 574: unexpected token at '{"foo":{"bar":"baz quux"}}' - (JSON::ParserError)
/usr/lib/ruby/gems/1.8/gems/json_pure-1.1.9/lib/json/common.rb:122:in `parse'
/usr/lib/ruby/gems/1.8/gems/json_pure-1.1.9/lib/json/common.rb:122:in `parse'
/usr/lib/ruby/gems/1.8/gems/chef-server-slice-0.7.12/app/controllers/nodes.rb:91:in `create'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/abstract_controller.rb:315:in `send'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/abstract_controller.rb:315:in `_call_action'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/abstract_controller.rb:289:in `_dispatch'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/controller/merb_controller.rb:252:in `_dispatch'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/dispatch/dispatcher.rb:100:in `dispatch_action'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/dispatch/dispatcher.rb:100:in `synchronize'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/dispatch/dispatcher.rb:100:in `dispatch_action'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/dispatch/dispatcher.rb:74:in `handle'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/dispatch/dispatcher.rb:36:in `handle'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/application.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/middleware/static.rb:28:in `call'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/handler/mongrel.rb:82:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/mongrel.rb:38:in `start_server'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:298:in `start_at_port'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:95:in `spawn_worker'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:139:in `start'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:138:in `upto'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:138:in `start'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:137:in `catch'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/rack/adapter/abstract.rb:137:in `start'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/server.rb:174:in `bootup'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/server.rb:159:in `daemonize'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/server.rb:143:in `fork'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/server.rb:143:in `daemonize'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core/server.rb:35:in `start'
/usr/lib/ruby/gems/1.8/gems/merb-core-1.0.12/lib/merb-core.rb:170:in `start'
/usr/lib/ruby/gems/1.8/gems/chef-server-0.7.12/bin/chef-server:69
/usr/bin/chef-server:19:in `load'
/usr/bin/chef-server:19
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
json_str = <<-EOS
{
"foo": {
"bar": "baz\tquux"
}
}
EOS
puts json_str
JSON.parse(json_str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment