nesquena / rabl

General ruby templating with json, bson, xml, plist and msgpack support
http://blog.codepath.com/2011/06/27/building-a-platform-api-on-rails/
MIT License
3.64k stars 334 forks source link

Error messages (call stack) do not render correctly. #423

Open jontonsoup opened 11 years ago

jontonsoup commented 11 years ago

This error happens for all my controllers and views that use rabl (only when there is some sort of error in the file...not during normal use when everything works). The errors in my files can be anything from typos to nil errors, but the same error that is returned to the front end is as follows:

NoMethodError at /api/v1/search_terms/new.json

undefined method `each' for nil:NilClass

(gem) rack-1.4.5/lib/rack/etag.rb, line 58

   53             headers.key?('ETag') || headers.key?('Last-Modified')
   54         end
   55   
   56         def digest_body(body)
   57           parts = []
>  58           body.each { |part| parts << part }
   59           string_body = parts.join
   60           digest = Digest::MD5.hexdigest(string_body) unless string_body.empty?
   61           [digest, parts]
   62         end
   63     end

App backtrace

Full backtrace

This error is pretty useless since it doesn't even show a backtrace in the application stack. I'm using: ruby "1.9.3"

gem 'asset_sync', '0.5.4' gem 'aws-sdk', '1.3.9' gem 'jquery-rails', '2.2.0' gem 'geocoder', '1.1.6' gem 'haml-rails', "~> 0.4" gem 'newrelic_rpm', '3.5.0.1' gem 'pg', '0.14.1' gem 'pg_search', '0.5.7' gem 'possessive', '1.0.1' gem 'spree_social', :git => "git://github.com/spree/spree_social.git", :branch => "1-3-stable" gem 'rails', '3.2.11' gem 'spree', '1.3.2' gem 'spree_auth_devise', :github => "spree/spree_auth_devise", :branch => "1-3-stable" gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git', :branch => "1-3-stable" gem 'spree_print_invoice' , :git => 'git://github.com/Walk-By/spree_print_invoice.git' gem "sunspot_autocomplete", ">= 0.0.3", :git => "git://github.com/xponrails/sunspot_autocomplete.git" gem "sunspot_rails", "~> 2.0.0" gem 'tax_cloud', '0.2.0' gem 'thin', '1.5.0' gem 'urbanairship', '2.2.0' gem 'haml', '3.1.7'

Any intuition on this?

Thanks, Jon

DriesS commented 11 years ago

You have a fix for this? I encounter also this problem.

nesquena commented 11 years ago

Hmm will look into this soon, thanks for bringing it to my attention. Odd

tispratik commented 11 years ago

+1. I do not see the stack trace showing the line numbers in the rabl file.

mariozaizar commented 11 years ago

+1 Seeing the Rabl line numbers could be really helpful.

App log:

INFO      Rendered api/v1/foo/bar/index.rabl 
INFO    Completed 500 Internal Server Error in 1348ms

When I render it manually from the console, I see the error. But I'm still can't see what line number is breaking:

NoMethodError: undefined method `all_activity' for nil:NilClass
  from (eval):4:in `block in render'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:79:in `call'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:79:in `node'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:42:in `block in compile_hash'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:41:in `each'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:41:in `compile_hash'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:21:in `block in build'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:156:in `cache_results'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/builder.rb:20:in `build'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/engine.rb:49:in `to_hash'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/engine.rb:61:in `to_json'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/engine.rb:37:in `block in render'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/engine.rb:277:in `cache_results'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/engine.rb:37:in `render'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl/renderer.rb:49:in `render'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/rabl-0.7.10/lib/rabl.rb:73:in `render'
  from (irb):108
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
  from /home/foo/bar/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
  from script/rails:6:in `require'
nesquena commented 11 years ago

Anyone interested in helping come up with a pull request for this?