Sidekiq: Sidekiq Web UI failing with authentication Rails 5rc1

Created on 10 May 2016  路  7Comments  路  Source: mperham/sidekiq

New failing point to get the Sidekiq Web UI working in Rails 5rc1.

The Sidekiq Web UI works without authentication. I followed your guide to add Devise authentication and it fails in the catch_json_parse_errors.rb middleware for "undefined method `failure_app' for nil:NilClass". See code and error below.

It seems Sidekiq Web UI uses Devise's login form, so I tried logging in but same failure when I go to /sidekiq.

Any suggestions on how to solve this?

Using Ruby 2.3.0, Rails 5.0.0.rc1, Rack 2.0.0.rc1, Sinatra master, Sidekiq 4.1.2, Redis 3.3.0, Devise 4.1.0.

routes.rb
require 'sidekiq/web'
Rails.application.routes.draw do
  devise_for :users

  authenticate :users do
    mount Sidekiq::Web => '/sidekiq'
  end
  ...
end

Started GET "/sidekiq" for ::1 at 2016-05-10 09:01:13 -0700

NoMethodError - undefined method `failure_app' for nil:NilClass:
  devise (4.1.0) lib/devise/delegator.rb:11:in `failure_app'
  devise (4.1.0) lib/devise/delegator.rb:5:in `call'
  warden (1.2.6) lib/warden/manager.rb:142:in `call_failure_app'
  warden (1.2.6) lib/warden/manager.rb:128:in `process_unauthenticated'
  warden (1.2.6) lib/warden/manager.rb:43:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/etag.rb:25:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/conditional_get.rb:25:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/head.rb:12:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  app/middleware/catch_json_parse_errors.rb:8:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/session/abstract/id.rb:222:in `context'
  rack (2.0.0.rc1) lib/rack/session/abstract/id.rb:216:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/cookies.rb:613:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activerecord (5.0.0.rc1) lib/active_record/migration.rb:552:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
  activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
  activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
  activesupport (5.0.0.rc1) lib/active_support/callbacks.rb:90:in `run_callbacks'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  web-console (3.1.1) lib/web_console/middleware.rb:131:in `call_app'
  web-console (3.1.1) lib/web_console/middleware.rb:28:in `block in call'
  web-console (3.1.1) lib/web_console/middleware.rb:18:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (5.0.0.rc1) lib/rails/rack/logger.rb:36:in `call_app'
  railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in `block in call'
  activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
  activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (5.0.0.rc1) lib/active_support/tagged_logging.rb:70:in `tagged'
  railties (5.0.0.rc1) lib/rails/rack/logger.rb:24:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/method_override.rb:22:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/runtime.rb:22:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  activesupport (5.0.0.rc1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/executor.rb:12:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  actionpack (5.0.0.rc1) lib/action_dispatch/middleware/static.rb:136:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack (2.0.0.rc1) lib/rack/sendfile.rb:111:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  rack-mini-profiler (0.9.9.2) lib/mini_profiler/profiler.rb:281:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  railties (5.0.0.rc1) lib/rails/engine.rb:522:in `call'
  newrelic_rpm (3.15.2.317) lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
  puma (3.4.0) lib/puma/configuration.rb:224:in `call'
  puma (3.4.0) lib/puma/server.rb:569:in `handle_request'
  puma (3.4.0) lib/puma/server.rb:406:in `process_client'
  puma (3.4.0) lib/puma/server.rb:271:in `block in run'
  puma (3.4.0) lib/puma/thread_pool.rb:114:in `block in spawn_thread'

Most helpful comment

I solved this. I missed the singular vs plural convention for :user when passing into authenticate. (Posting incase someone else runs into same issue.)

  authenticate :user do    # :user needs to be singular
    mount Sidekiq::Web => '/sidekiq'
  end

All 7 comments

Looks like a Devise issue.

@mperham Ok... I have Devise working fine in my Rails app with my other endpoints. This error only occurs when I'm trying to authenticate Sidekiq's Web UI access using your documented method. Is there some other setting or configuration that I could have missed? Or what in Sidekiq's Web UI would be triggering an error in Devise? Any high level insights of your architecture will be helpful to isolate the issue and fix it.

I wonder whether devise 4.1 works with this bleeding edge stuff. Either way, Sidekiq::Web has nothing to do with Devise so the issue must be in the app config.

I see... well that helps to narrow my debugging.

I solved this. I missed the singular vs plural convention for :user when passing into authenticate. (Posting incase someone else runs into same issue.)

  authenticate :user do    # :user needs to be singular
    mount Sidekiq::Web => '/sidekiq'
  end

@hmistry could u tell me your sinatra's commit version?

@seaify The problem was solved, my mistake, as I stated above. But here's the version:

  remote: git://github.com/sinatra/sinatra.git
  revision: a9dc7ef1a73922cca133c71cfc3bbbe643dc4304
  specs:
    sinatra (2.0.0.pre.alpha)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

agrobbin picture agrobbin  路  4Comments

mperham picture mperham  路  3Comments

edgarjs picture edgarjs  路  3Comments

bartimaeus picture bartimaeus  路  3Comments

sandstrom picture sandstrom  路  3Comments