genghis icon indicating copy to clipboard operation
genghis copied to clipboard

can't show/edit data with NAN

Open remoe opened this issue 11 years ago • 10 comments

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'

remoe avatar May 25 '13 10:05 remoe

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?

bobthecow avatar May 27 '13 07:05 bobthecow

The issue is with Not-A-Number data:

{ foo: NaN }

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

remoe avatar May 27 '13 07:05 remoe

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

intech avatar Jun 23 '13 20:06 intech

I'm sorry for spoiling your life :(

bobthecow avatar Jun 24 '13 17:06 bobthecow

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

bobthecow avatar Jun 25 '13 06:06 bobthecow

Justin thanks, it works!

remoe avatar Jun 25 '13 18:06 remoe

Hi

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

remoe avatar Jan 04 '14 17:01 remoe

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.

bobthecow avatar Jan 04 '14 18:01 bobthecow

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

rfink avatar Jan 07 '14 15:01 rfink

@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.

bobthecow avatar Jan 07 '14 18:01 bobthecow