heroku/identity — pull request #92 by mfine (2014-01-07 21:31:07+00:00)
Title: CSRF parsing can cause a bad stack trace

This trace showed up:

```
Puma caught this error: undefined method `size' for nil:NilClass
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/utils.rb:445:in `[]='
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/utils.rb:76:in
`block in parse_query'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/utils.rb:66:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/utils.rb:66:in
`parse_query'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/request.rb:263:in
`cookies'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/cookie.rb:104:in
`unpacked_cookie_data'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/cookie.rb:98:in
`extract_session_id'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:43:in
`load_session_id!'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:32:in
`[]'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:262:in
`current_session_id'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:268:in
`session_exists?'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:107:in
`exists?'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:122:in
`load_for_read!'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:59:in
`[]'
/app/vendor/bundle/ruby/2.0.0/gems/rack_csrf-2.4.0/lib/rack/csrf.rb:64:in
`token'
/app/vendor/bundle/ruby/2.0.0/gems/rack_csrf-2.4.0/lib/rack/csrf.rb:37:in
`call'
/app/lib/identity/csrf.rb:9:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in
`context'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/deflater.rb:13:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/rack-ssl-1.3.2/lib/rack/ssl.rb:27:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/rack-instruments-0.3.2/lib/rack/instruments.rb:52:in
`block in call'
/app/vendor/bundle/ruby/2.0.0/gems/slides-0.2.0/lib/slides.rb:19:in
`log_array'
/app/vendor/bundle/ruby/2.0.0/gems/slides-0.2.0/lib/slides.rb:7:in `log'
/app/vendor/bundle/ruby/2.0.0/gems/rack-instruments-0.3.2/lib/rack/instruments.rb:51:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/rack-1.4.1/lib/rack/builder.rb:134:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/puma-1.6.3/lib/puma/server.rb:412:in
`handle_request'
/app/vendor/bundle/ruby/2.0.0/gems/puma-1.6.3/lib/puma/server.rb:306:in
`process_client'
/app/vendor/bundle/ruby/2.0.0/gems/puma-1.6.3/lib/puma/server.rb:215:in
`block in run'
/app/vendor/bundle/ruby/2.0.0/gems/puma-1.6.3/lib/puma/thread_pool.rb:94:in
`call'
/app/vendor/bundle/ruby/2.0.0/gems/puma-1.6.3/lib/puma/thread_pool.rb:94:in
`block in spawn_thread'
```

Issues in parse_query around session.token reading. Catch the exception and return a 500.

/cc @brandur