Bug #36182
closedundefined method `[]' for nil:NilClass" or undefined method `last' for nil:NilClass" when generating Host - applied errata report
Description
Clone from https://bugzilla.redhat.com/show_bug.cgi?id=2176368
Description of problem:
Getting one of the following errors while generating the Host - Applied Errata report.
- undefined method `[]' for nil:NilClass"
- undefined method `last' for nil:NilClass"
The first error is caused by task input returns nil because the code is fetching it the wrong way.
The second error will happen if an erratum that user tried to apply to the hosts doesn't exist in the database or is invalid. E.g. typo error.
Steps to reproduce:
1. In the "Run Job" page, use Katello SSH to apply errata to one or more hosts. In the errata field, simply enter any invalid errata.
2. Wait for the job to finish.
3. Generate the Host - Applied Errata report.
Actual results:
undefined method `last' for nil:NilClass"
Expected results:
Report can be generated successfully.
Additional info: