Project

General

Profile

Bug #14824

undefined method `[]' for nil:NilClass - subscription-manager register

Added by Thomas McKay over 3 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Unsure what caused this change, but it seems like Engine.routes.router.recognize(link 1 below) is not returning params correctly any longer so the references in the case statement fail accessing id. Is this from rails4?

# subscription-manager register --org megacorp --activationkey minimal
The system has been registered with ID: 71eba30e-d833-4804-b23a-aadb27aa6cf6 
undefined method `[]' for nil:NilClass

The system is successfully registered to katello but further calls fail (fetching entitlements, etc.). Once registered 'subscription-manager refresh' will also exhibit the nil error for easy testing/reproducing.

1: https://github.com/Katello/katello/blob/master/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb#L438

Associated revisions

Revision 421342f6 (diff)
Added by Chris Duryee over 3 years ago

Fixes #14824 - strip out extraneous nil from `recognize` call

We had a `_` that was used to eat a `nil` which is no longer needed,
see https://github.com/rails/rails/commit/dd1f23df7.

Revision e9b65cbd
Added by Chris Duryee over 3 years ago

Merge pull request #6004 from beav/extraneous-nil

Fixes #14824 - strip out extraneous nil from `recognize` call

History

#1 Updated by Thomas McKay over 3 years ago

This workaround works but I don't know the implications or the real underlying problem/fix.

$ git diff
WARNING: terminal is not fully functional
-  (press RETURN)
diff --git a/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb b/app/controllers/katellindex 58431b4..51d6759 100644
--- a/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb
+++ b/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb
@@ -435,7 +435,7 @@ module Katello
     def authorize_proxy_routes
       deny_access unless (authenticate || authenticate_client)

-      route, _, params = Engine.routes.router.recognize(request) do |rte, match, parameters|
+      route, params, _ = Engine.routes.router.recognize(request) do |rte, match, parameters|
         break rte, match, parameters if rte.name
       end

#2 Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/6004 added

#3 Updated by Chris Duryee over 3 years ago

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

#4 Updated by Eric Helms over 3 years ago

  • Legacy Backlogs Release (now unused) set to 86

#5 Updated by Wagner Sartori over 3 years ago

I'm running katello 3 rc5 now, and I was having the same "undefined method `[]' for nil:NilClass" problem.

I reverted the patch, to use the _ and now it's working again. Maybe my rails wasn't updated with katello 3 and there's some dependencies with wrong versions on the yum repositories somewhere.

#6 Updated by Marvin Beckers over 3 years ago

I'm also running Katello 3.0 RC5 (brand new installation, set up today following standard procedure) and facing the same problem. Here's an extract from /var/log/foreman/production.log:

2016-05-25 14:02:20 [app] [I] Started GET "/rhsm/consumers/8ab39aa2-de2f-485b-8120-9b630ed89be4/certificates?serials=2798807315053081947" for <IP> at 2016-05-25 14:02:20 +0200
2016-05-25 14:02:20 [app] [I] Processing by Katello::Api::Rhsm::CandlepinProxiesController#get as JSON
2016-05-25 14:02:20 [app] [I]   Parameters: {"serials"=>"2798807315053081947", "id"=>"8ab39aa2-de2f-485b-8120-9b630ed89be4"}
2016-05-25 14:02:20 [katello/cp_proxy] [E] NoMethodError: undefined method `[]' for nil:NilClass
 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.rc5/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb:461:in `authorize_proxy_routes'
[..]

I cannot confirm that reverting the patch works, but maybe I'm just doing it wrong. As RC5 is supposed to include the commit fixing this issue, this issue seems either not completely fixed or is another problem altogether. I'm not sure here, but will happily assist in debugging.

#7 Updated by george lim over 3 years ago

I tried adding the _ back in but it still doesn't work for me. The same error occurs.

#8 Updated by Justin Sherrill over 3 years ago

  • Status changed from Closed to Assigned
  • Assignee set to Chris Duryee

Reopening as this was reported by a user:


    2016-06-01 01:43:58 [katello/cp_proxy] [E] NoMethodError: undefined method `[]' for nil:NilClass
     | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.rc5/app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb:461:in `authorize_proxy_routes'
     | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:424:in `block in make_lambda'
     | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:143:in `call'
     | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:143:in `block in halting_and_conditional'
     | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `call'
     | /opt/rh/rh-ror41/root/usr/share/gems/gems/activesupport-4.1.5/lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'

on subscription-manager-1.15.9-15.el7.centos.0.1.x86_64 when using an activation key

#9 Updated by Eric Helms over 3 years ago

  • Status changed from Assigned to Closed

I'm going to revert this to closed in favor of http://projects.theforeman.org/issues/15192 which opened around this specific issue so that this issue can remain as was.

Also available in: Atom PDF