Bug 1360771

Summary: Dashboard gives undefined method `label' for nil:NilClass
Product: Red Hat Satellite Reporter: Sean O'Keeffe <sokeeffe>
Component: DashboardAssignee: Justin Sherrill <jsherril>
Status: CLOSED DUPLICATE QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 6.2.0CC: bbuckingham, bkearney, jsherril, mmccune, paul.seymour, rudneibertol, sthirugn, xdmoon
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-16 21:51:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sean O'Keeffe 2016-07-27 12:44:25 UTC
Description of problem:

After 6.2 upgrade the dashboard no longer loads and errors with "undefined method `label' for nil:NilClass". We think this happens if the user has deleted a bunch of old stopped tasks before. The newer dynflows provide this functionality via a rake task, but we need to handle it if a user has removed them before. 

Version-Release number of selected component (if applicable):
6.2

How reproducible:
not sure

Steps to Reproduce:
1. install 6.1
2. sync something so you create some tasks
3. delete some of the tasks using the console.
4. upgrade to 6.2
5. dashboard wont load

Actual results:
dashboard wont load

Expected results:
dashboard to display correctly

Additional info:

Comment 1 Sean O'Keeffe 2016-07-27 12:46:56 UTC
You can delete a tasks using, maybe replacing the label.

# foreman-rake console  
ForemanTasks::Task.where(:state => :stopped).where(:label => "Actions::Katello::Repository::Sync").destroy_all

Comment 2 Bryan Kearney 2016-07-27 14:17:07 UTC
Upstream bug assigned to jsherril

Comment 6 Paul Seymour 2016-08-07 09:36:45 UTC
OK hitting this myself and raised a dupe BZ#1364768 as my search-foo was not great.

Now how to resolve it ?

Comment 7 Tomer Brisker 2016-08-07 12:53:01 UTC
*** Bug 1364768 has been marked as a duplicate of this bug. ***

Comment 8 Paul Seymour 2016-08-08 06:17:38 UTC
I managed to fix this (or workaround it at least) by applying this:-

https://github.com/Katello/katello/pull/6028

Cleared sessions & katello-service restart

Comment 9 Rudnei Bertol Jr. 2016-08-09 20:49:03 UTC
I've same error, and decided updating file /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.68/app/models/katello/content_view_history.rb

line ~45 

-def humanized_action
-  case self.task.label
-  when "Actions::Katello::ContentViewVersion::Export"
-    _("Exported version")
-  when "Actions::Katello::ContentView::Publish"
-    _("Published new version")
-  when "Actions::Katello::ContentView::Promote"
-    _("Promoted to %{environment}") % { :environment => self.environment.name }
-  when "Actions::Katello::ContentView::Remove"
-    _("Deleted from %{environment}") % { :environment => self.environment.name }
-  end
-end

+def humanized_action
+  case self.task.try(:label)
+  when "Actions::Katello::ContentViewVersion::Export"
+    _("Exported version")
+  when "Actions::Katello::ContentView::Publish"
+    _("Published new version")
+  when "Actions::Katello::ContentView::Promote"
+    _("Promoted to %{environment}") % { :environment => self.environment.try(:name) || _('Unknown') }
+  when "Actions::Katello::ContentView::Remove"
+    _("Deleted from %{environment}") % { :environment => self.environment.try(:name) || _('Unknown')}
+  else
+    _("Unknown Action")
+  end
+end


Clear all tasks in DynFlow, database and pulp.
Restart all services.

Comment 10 Mike McCune 2016-08-16 21:51:27 UTC

*** This bug has been marked as a duplicate of bug 1361793 ***