Bug #37215
closedGetting "undefined method '#id' for NilClass::Jail (NilClass)" error when generating Ansible inventory report
Description
Clone from bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=2266794
Description of problem:
Getting the following error when generating the Ansible inventory report.
Safemode::NoMethodError undefined method '#id' for NilClass::Jail (NilClass) --- - "/usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:22:in `method_missing'" - Ansible - Ansible Inventory:89:in `block in initialize' - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block (2 levels) in each_record'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `each'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:40:in `block in each_record'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:245:in `block in in_batches'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `loop'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `in_batches'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each'" - "/usr/share/gems/gems/activerecord-6.1.7.4/lib/active_record/relation/batches/batch_enumerator.rb:39:in `each_record'" - "/usr/share/gems/gems/safemode-1.3.8/lib/safemode/jail.rb:31:in `method_missing'" - Ansible - Ansible Inventory:83:in `initialize' - "/usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'" - "/usr/share/gems/gems/safemode-1.3.8/lib/safemode.rb:52:in `eval'" - "/usr/share/foreman/app/services/foreman/renderer/safe_mode_renderer.rb:7:in `render'" - "/usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'" - "/usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'" - "/usr/share/foreman/app/models/template.rb:172:in `render'" - "/usr/share/foreman/app/models/report_composer.rb:241:in `render'" - "/usr/share/foreman/app/jobs/template_render_job.rb:12:in `block in perform'" - "/usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'" - "/usr/share/foreman/app/jobs/template_render_job.rb:9:in `perform'" - "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/execution.rb:48:in `block in perform_now'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:117:in `block in run_callbacks'" - "/usr/share/gems/gems/i18n-1.13.0/lib/i18n.rb:322:in `with_locale'" - "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/translation.rb:9:in `block (2 levels) in <module:Translation>'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in `instance_exec'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in `block in run_callbacks'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/core_ext/time/zones.rb:66:in `use_zone'" - "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/timezones.rb:9:in `block (2 levels) in <module:Timezones>'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in `instance_exec'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/callbacks.rb:126:in `block in run_callbacks'" - "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/instrumentation.rb:21:in `block in instrument'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications.rb:203:in `block in instrument'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'" - "/usr/share/gems/gems/activesupport-6.1.7.4/lib/active_support/notifications.rb:203:in `instrument'" - "/usr/share/gems/gems/activejob-6.1.7.4/lib/active_job/instrumentation.rb:31:in `instrument'"
How reproducible:
Easy
Steps to Reproduce:
1. Has some hosts not associated to any content view or LCE. The satellite host entry itself should be sufficient to reproduce.
2. Navigate to Monitor -> Report Templates -> "Ansible - Ansible Inventory" -> Click "Generate" button
3. Set "Yes" for Content Attributes and click Generate button.
Actual results:
Safemode::NoMethodError
undefined method '#id' for NilClass::Jail (NilClass)
Expected results:
Report generates successfully
Additional info:
Similar issue to bug #2256411 but different report template.
Updated by The Foreman Bot 9 months ago
- Status changed from New to Ready For Testing
- Assignee set to Hao Yu
- Pull request https://github.com/theforeman/foreman/pull/10074 added
Updated by ebarrere please_edit_me 9 months ago
vi won wrote in #note-2:
Did some testing. We use this as well to sync inventory from Foreman->AWX. It seems to only happen when "Content Attributes" is set to yes. If you disable that option in the report, it seems to generate ok.
Thanks! I'm having the same issue and this workaround will save me.
Updated by Hao Yu 8 months ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|b6bae776dc81364f474b455d36905097598bfa5c.
Updated by Ewoud Kohl van Wijngaarden 5 months ago
- Triaged changed from No to Yes
Updated by The Foreman Bot 5 months ago
- Pull request https://github.com/theforeman/foreman/pull/10234 added