Actions
Bug #3045
closedReports with no logs cause undefined method `each' for nil:NilClass (NoMethodError)
Description
When loading a report with no useful log messages, params["report"]["logs"]
arrives as nil rather than an empty array.
The report processor is generating []
as you can see here:
irb(main):017:0> r.logs => [#<Puppet::Util::Log:0x7f873ffe87b0 @source="Puppet", @level=:notice, @tags=["notice"], @message="Finished catalog run in 2.83 seconds", @time=Fri Sep 06 16:55:46 +0000 2013>] irb(main):018:0> r.generate_report => {"host"=>"builder.fm.example.net", "logs"=>[], "status"=>{"failed_restarts"=>0, "skipped"=>0, "restarted"=>0, "pending"=>0, "failed"=>0, "applied"=>1}, "metrics"=>{"resources"=>{"skipped"=>6, "scheduled"=>0, "restarted"=>0, "out_of_sync"=>1, "failed_to_restart"=>0, "failed"=>0, "total"=>52, "changed"=>1}, "events"=>{"success"=>1, "total"=>1, "failure"=>0}, "time"=>{"kernel_parameter"=>0.111702, "filebucket"=>0.000361, "config_retrieval"=>4.38487815856934, "anchor"=>0.001314, "file"=>1.536893, "augeas"=>0.381903, "total"=>6.63197715856934, "package"=>0.001708, "service"=>0.213218}, "changes"=>{"total"=>1}}, "reported_at"=>"2013-09-06 16:55:23 UTC"}
But here it's appearing as nil, causing an error when trying to iterate over the variable:
Started POST "/api/reports" for 192.168.101.10 at 2013-09-06 17:11:25 +0000 Processing by Api::V2::ReportsController#create as JSON Parameters: {"report"=>{"host"=>"builder.fm.example.net", "logs"=>nil, "status"=>{"failed_restarts"=>0, "skipped"=>0, "restarted"=>0, "pending"=>0, "failed"=>0, "applied"=>1}, "metrics"=>{"resources"=>{"skipped"=>6, "scheduled"=>0, "restarted"=>0, "out_of_sync"=>1, "failed_to_restart"=>0, "failed"=>0, "total"=>52, "changed"=>1}, "events"=>{"success"=>1, "total"=>1, "failure"=>0}, "time"=>{"kernel_parameter"=>0.111702, "filebucket"=>0.000361, "config_retrieval"=>4.38487815856934, "anchor"=>0.001314, "file"=>1.536893, "augeas"=>0.381903, "total"=>6.63197715856934, "package"=>0.001708, "service"=>0.213218}, "changes"=>{"total"=>1}}, "reported_at"=>"2013-09-06 16:55:23 UTC"}} processing report for builder.fm.example.net undefined method `each' for nil:NilClass (NoMethodError) /usr/share/foreman/app/models/report.rb:191:in `import_log_messages' /usr/share/foreman/app/models/report.rb:110:in `import' /usr/share/foreman/app/controllers/api/v2/reports_controller.rb:19:in `create'
Updated by Greg Sutcliffe over 11 years ago
- Status changed from New to Ready For Testing
- Assignee set to Greg Sutcliffe
Updated by Greg Sutcliffe over 11 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 823e4ba85415837cf89ed4babe316af67eaccc4b.
Actions