Refactor #18664

Ignore missing actions in SmartProxyAuth calls to skip_before_action

Added by Dominic Cleal over 5 years ago. Updated almost 4 years ago.

Target version:
Bugzilla link:
Fixed in Releases:
Found in Releases:


The SmartProxyAuth controller concern is designed to work on both the UI and API base controller and calls skip_before_action to skip require_login and set_taxonomy action filters. These are only present on the UI base controller though, but under Rails 5.0 this raises an exception:

gems/ruby-2.3.0@foreman/gems/activesupport-5.0.0/lib/active_support/callbacks.rb:641:in `block (2 levels) in skip_callback': Before process_action callback :require_login has not been defined (ArgumentError)
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:637:in `each'
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:637:in `block in skip_callback'
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:568:in `block in _update_callbacks'
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:566:in `reverse_each'
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:566:in `
from gems/activesupport-5.0.0/lib/active_support/callbacks.rb:636:in `skip_callback'
from gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:210:in `block (3 levels) in <module:ClassMethods>'
from gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:93:in `block in _insert_callbacks'
from gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:92:in `each'
from gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:92:in `_insert_callbacks'
from gems/actionpack-5.0.0/lib/abstract_controller/callbacks.rb:209:in `block (2 levels) in <module:ClassMethods>'
from app/controllers/concerns/foreman/controller/smart_proxy_auth.rb:9:in `add_smart_proxy_filters'

I think it's harmless enough to pass the raise => false argument in on these two filters and ignore errors if the filters are undefined, since the concern has good test coverage. The concern is used in plugins too, so refactoring it into separate UI/API concerns may be disruptive.

Associated revisions

Revision ba8f06a4 (diff)
Added by Dominic Cleal over 5 years ago

fixes #18664 - ignore missing callbacks in SmartProxyAuth concern

Filters that are only registered on the UI controllers cause errors
when using SmartProxyAuth on an API controller under Rails 5.0.


#1 Updated by The Foreman Bot over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request added

#2 Updated by Dominic Cleal over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal over 5 years ago

  • Legacy Backlogs Release (now unused) set to 209

Also available in: Atom PDF