SquareSquash / web

Squash’s front-end and API host.
http://www.squash.io
Apache License 2.0
962 stars 135 forks source link

API call from javascript plugin throws error: private method `select' called for nil:NilClass #65

Open ralfschimmel opened 11 years ago

ralfschimmel commented 11 years ago

Included the javascript plugin in my application, enabled CORS in squash and triggered an Error. The following was the result in the log:

Started OPTIONS "/api/1.0/notify" for 192.168.56.73 at 2013-03-20 13:51:52 +0100
Started POST "/api/1.0/notify" for 192.168.56.73 at 2013-03-20 13:51:52 +0100
Processing by Api::V1Controller#notify as */*
  Parameters: {"api_key"=>"Xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx", "environment"=>"production", "client"=>"javascript", "revision"=>"84bf092b2470debef3d494b96ae4b057d9d49a77", "class_name"=>"Error", "message"=>"Test JavaScript error!", "backtraces"=>[{"name"=>"Active Thread", "faulted"=>true, "backtrace"=>nil}], "capture_method"=>"callers", "occurred_at"=>"2013-03-20T12:52:21Z", "schema"=>"https", "host"=>"www.test.nl", "path"=>"/", "query"=>"", "fragment"=>"#/login", "user_agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22", "screen_width"=>1920, "screen_height"=>1200, "window_width"=>1276, "window_height"=>721, "color_depth"=>24}
Completed 200 OK in 1ms (ActiveRecord: 0.0ms)
-- ERROR IN OccurrencesWorker 44860100 --
private method `select' called for nil:NilClass
/home/beheer/squash/lib/blamer.rb:222:in `blamed_revision'
/home/beheer/squash/lib/blamer.rb:195:in `bug_search_criteria'
/home/beheer/squash/lib/blamer.rb:119:in `find_or_create_bug!'
/home/beheer/squash/lib/workers/occurrences_worker.rb:86:in `perform'
/home/beheer/squash/lib/workers/occurrences_worker.rb:43:in `perform'
/home/beheer/squash/lib/background_runner/multithread.rb:32:in `block in run'
/home/beheer/squash/lib/multithread.rb:62:in `block (3 levels) in spinoff'
/home/beheer/squash/lib/multithread.rb:100:in `with_dogfood'
/home/beheer/squash/lib/multithread.rb:62:in `block (2 levels) in spinoff'
/home/beheer/squash/vendor/bundle/ruby/1.9.1/bundler/gems/rails-f1efecfc3f00/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/home/beheer/squash/lib/multithread.rb:95:in `with_connection'
/home/beheer/squash/lib/multithread.rb:62:in `block in spinoff'
/home/beheer/squash/lib/multithread.rb:77:in `call'
/home/beheer/squash/lib/multithread.rb:77:in `block (4 levels) in start'
/home/beheer/squash/lib/multithread.rb:77:in `loop'
/home/beheer/squash/lib/multithread.rb:77:in `block (3 levels) in start'
/home/beheer/squash/lib/multithread.rb:77:in `catch'
/home/beheer/squash/lib/multithread.rb:77:in `block (2 levels) in start'
{"client"=>"javascript", "revision"=>"84bf092b2470debef3d494b96ae4b057d9d49a77", "message"=>"Test JavaScript error!", "backtraces"=>[{"name"=>"Active Thread", "faulted"=>true, "backtrace"=>nil}], "capture_method"=>"callers", "occurred_at"=>"2013-03-20T12:52:21Z", "schema"=>"https", "host"=>"www.test.nl", "path"=>"/", "query"=>"", "fragment"=>"#/login", "user_agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22", "screen_width"=>1920, "screen_height"=>1200, "window_width"=>1276, "window_height"=>721, "color_depth"=>24}
-- END ERROR 44860100 --
RISCfuture commented 11 years ago

The issue is the JS client is not reporting a backtrace. Note this snippet from the request parameters:

[{"name"=>"Active Thread", "faulted"=>true, "backtrace"=>nil}]

Not sure if it's an actual bug in the JS client, or if it's a weird browser quirk, or something to do with the way you are catching the exception.

ralfschimmel commented 11 years ago

The exception is thrown using a setTimeout in the console just for testing, I did not change anything to the catching mechanism.

var error = new Error("Test JavaScript error!");
throw(error);

This might not give a backtrace though, which can result in nil?

RISCfuture commented 11 years ago

Are you using the latest version of the Squash Javascript library? Looking at the client.coffee file, it seems like there is no possibly way for it to be nil.

ralfschimmel commented 11 years ago

Yeah, just checked but 'git pull' tells me I'm up-to-date.

RISCfuture commented 11 years ago

OK, you'll probably have to do some debugging then. You can edit the client.coffee file and add some console.debugs to help figure out what's wrong. The notify method would be where to check. It's fairly straightforward.

ralfschimmel commented 11 years ago

I'll give it a go, cheers so far.