bobthecow / genghis

The single-file MongoDB admin app
http://genghisapp.com
MIT License
1.45k stars 164 forks source link

can't show/edit data with NAN #115

Open remoe opened 11 years ago

remoe commented 11 years ago

Hi

I try to show/edit a collection with NAN/bad data. But it is currently not possible to show/edit bad data. It throws:

JSON::GeneratorError - 810: NaN not allowed in JSON:
.../gems/2.0.0/gems/sinatra-contrib-1.3.2/lib/sinatra/json.rb:119:in `to_json'
.../gems/2.0.0/gems/sinatra-contrib-1.3.2/lib/sinatra/json.rb:119:in `to_json'
.../gems/2.0.0/gems/sinatra-contrib-1.3.2/lib/sinatra/json.rb:119:in `json'
genghis.rb:690:in `genghis_json'
genghis.rb:1013:in `block in <class:Server>'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:1292:in `call'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:1292:in `block in compile!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in `[]'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in `block (3 levels) in route!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:876:in `route_eval'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:860:in `block (2 levels) in route!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:897:in `block in process_route'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:in `catch'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:895:in `process_route'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:859:in `block in route!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:858:in `each'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:858:in `route!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:963:in `block in dispatch!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `block in invoke'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `catch'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `invoke'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:960:in `dispatch!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:in `block in call!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `block in invoke'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `catch'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:946:in `invoke'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:794:in `call!'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:780:in `call'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in `call'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in `call
'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:in `call'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
.../gems/2.0.0/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in `call'

.../gems/2.0.0/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
.../gems/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:124:in `call'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:1417:in `block in call'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:1499:in `synchronize'
.../gems/2.0.0/gems/sinatra-1.3.6/lib/sinatra/base.rb:1417:in `call'
.../gems/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in `service'
bobthecow commented 11 years ago

How did you get a document with bad data in the first place? What exactly does such a document look like? Can you give me an example? Are you having trouble fixing it, or viewing it, or something else?

remoe commented 11 years ago

The issue is with Not-A-Number data:

{ foo: NaN }

You can't view or fixing such values currently with genghis.

intech commented 11 years ago

This error spoils life when developing applications have to use the familiar mongo shell :(

bobthecow commented 11 years ago

I'm sorry for spoiling your life :(

bobthecow commented 11 years ago

This should be fixed in the develop branch. Do you mind taking a look and verifying the fix?

remoe commented 11 years ago

Justin thanks, it works!

remoe commented 10 years ago

Hi

This doesn't work on current 2.3.10. Are this changes lost? :)

bobthecow commented 10 years ago

It's still in the develop branch, as it was slated for a 2.4 release which hasn't happened yet. There have been a couple of 2.3.x releases, so I probably should have stuck it in one of those.

rfink commented 10 years ago

Did this entire commit get deleted? It's nowhere to be found in the repo, in any branch.

bobthecow commented 10 years ago

@rfink It looks like it's still in the 3.0 dev branch, which is where the next non-hotfix release will be coming from. Unfortunately, that's not much help for people who need this right now :P

I'll try to get a new hotfix out with this fix in it in the interim.