Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
Created June 30, 2011 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenhaddox/1055863 to your computer and use it in GitHub Desktop.
Save stevenhaddox/1055863 to your computer and use it in GitHub Desktop.
undefined method `[]' for nil:NilClass in OmniAuth Custom Strategy

RESOLVED

Figured out this error, please DISREGARD! We were forgetting to redirect to the callback_url at the end of the request_phase as we thought that was handled by OmniAuth (oops...)

To replicate this error you should be able to do the following:

Example folder structure:

parent-folder/
             |-oa-casport
             |-oa-casport-sinatra
  • Perform the following steps:

Ensure you have RVM with Ruby 1.9.2 and a gemset called oa-casport setup

$ cd oa-casport-sinatra
$ git checkout initial
$ bundle
$ bundle exec rackup
Visit the Sinatra app URL and click 'Sign in via CASPORT'
See the error_stacktrace.txt output if this worked right

I should note that I've put puts statements at the beginning and end of each method within the gem and can identify that this error is occuring after the request_phase within the gem is completed, but before any other method inside the gem is called...

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/utils.rb in set_cookie_header!

case header["Set-Cookie"]

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/session/cookie.rb in set_cookie

Utils.set_cookie_header!(headers, @key, cookie)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/session/abstract/id.rb in commit_session

set_cookie(env, headers, cookie.merge!(options))

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/session/abstract/id.rb in context

commit_session(env, status, headers, body)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/session/abstract/id.rb in call

context(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/head.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/sinatra-1.2.6/lib/sinatra/showexceptions.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/sinatra-1.2.6/lib/sinatra/base.rb in block in call

synchronize { prototype.call(env) }

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/sinatra-1.2.6/lib/sinatra/base.rb in synchronize

yield

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/sinatra-1.2.6/lib/sinatra/base.rb in call

synchronize { prototype.call(env) }

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/lint.rb in _call

status, headers, @body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/lint.rb in call

dup._call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/showexceptions.rb in call

@app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/commonlogger.rb in call

status, header, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/chunked.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/content_length.rb in call

status, headers, body = @app.call(env)

/usr/local/rvm/gems/ruby-1.9.2-p180@oa-casport/gems/rack-1.3.0/lib/rack/handler/webrick.rb in service

status, headers, body = @app.call(env)

/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb in service

si.service(req, res)

/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb in run

server.service(req, res)

/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb in block in start_thread

block ? block.call(sock) : run(sock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment