I'm using omniauth and omniauth-mapmyfitness-oauth2 to allow MapMyFitness users to sign in to my site.
Recently, I've had a few sign in attempts result in the error below. It doesn't look like any of the error is occurring in my Rails app's code - it seems like it's entirely within ruby, some gem(s), or the MapMyFitness API.
Any direction/information/suggestions on how to debug this at all would be greatly appreciated. I haven't experienced an issue like this before, so it's a huge learning opportunity.
NoMethodError (undefined method `strip' for nil:NilClass):
/usr/lib/ruby/1.9.1/net/http.rb:1435:in `block in initialize_http_header'
/usr/lib/ruby/1.9.1/net/http.rb:1433:in `each'
/usr/lib/ruby/1.9.1/net/http.rb:1433:in `initialize_http_header'
/usr/lib/ruby/1.9.1/net/http.rb:1862:in `initialize'
faraday (0.8.9) lib/faraday/adapter/net_http.rb:55:in `new'
faraday (0.8.9) lib/faraday/adapter/net_http.rb:55:in `create_request'
faraday (0.8.9) lib/faraday/adapter/net_http.rb:75:in `perform_request'
faraday (0.8.9) lib/faraday/adapter/net_http.rb:38:in `call'
faraday (0.8.9) lib/faraday/request/url_encoded.rb:14:in `call'
faraday (0.8.9) lib/faraday/connection.rb:253:in `run_request'
oauth2 (0.9.3) lib/oauth2/client.rb:90:in `request'
oauth2 (0.9.3) lib/oauth2/client.rb:135:in `get_token'
oauth2 (0.9.3) lib/oauth2/strategy/auth_code.rb:29:in `get_token'
omniauth-oauth2 (1.1.2) lib/omniauth/strategies/oauth2.rb:93:in `build_access_token'
omniauth-oauth2 (1.1.2) lib/omniauth/strategies/oauth2.rb:75:in `callback_phase'
omniauth (1.2.1) lib/omniauth/strategy.rb:227:in `callback_call'
omniauth (1.2.1) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
newrelic_rpm (3.8.0.218) lib/new_relic/rack/error_collector.rb:55:in `call'
newrelic_rpm (3.8.0.218) lib/new_relic/rack/agent_hooks.rb:32:in `call'
newrelic_rpm (3.8.0.218) lib/new_relic/rack/browser_monitoring.rb:27:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.18) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.18) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `_run__3877922931106558540__call__1275774963243928783__callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.18) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.18) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.18) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
airbrake (3.1.16) lib/airbrake/rails/middleware.rb:13:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.18) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.18) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.18) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.18) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.18) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.18) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
airbrake (3.1.16) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (3.1.16) lib/airbrake/user_informer.rb:12:in `call'
railties (3.2.18) lib/rails/engine.rb:484:in `call'
railties (3.2.18) lib/rails/application.rb:231:in `call'
railties (3.2.18) lib/rails/railtie/configurable.rb:30:in `method_missing'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'
I did poke into the /usr/lib/ruby/1.9.1/net/http.rb
file, and found a reference to .strip
right at line 1435:
def initialize_http_header(initheader)
@header = {}
return unless initheader
initheader.each do |key, value|
warn "net/http: warning: duplicated HTTP header: #{key}" if key?(key) and $VERBOSE
@header[key.downcase] = [value.strip]
end
end
I don't know what to do with that information, though.
omniauth-mapmyfitness-oauth2 has a weird requirement that ENV['MMF_API_KEY']
be defined for the library to work. (Weird to me, anyway. I'd love to know more about why it was set up this way.)
This is because it's using that environment variable on line 13 of its strategy file.
I recently migrated the server, and forgot to bring along this environment variable. Based on this answer I added two lines to a new file, /etc/profile.d/mapmyfitness.sh
, to make this available system-wide:
export MMF_API_KEY=my-key
export MMF_API_SECRET=my-secret