Report Template 'Host - Applied Errata' error "undefined method `value' for nil:NilClass"

Problem:
Hi,
when we try to user the report “Host - Applied Errata” we get the error “undefined method `value’ for nil:NilClass”, whichever combination of inputs we use.

Expected outcome:
Report to be generated without errors

Foreman and Proxy versions:
Foreman 3.7.1 / Katello 4.9.2

Foreman and Proxy plugin versions:

Installed Packages

    ansible-collection-theforeman-foreman-3.13.0-1.el8.noarch
    candlepin-4.3.1-1.el8.noarch
    candlepin-selinux-4.3.1-1.el8.noarch
    foreman-3.7.1-1.el8.noarch
    foreman-cli-3.7.1-1.el8.noarch
    foreman-debug-3.7.1-1.el8.noarch
    foreman-dynflow-sidekiq-3.7.1-1.el8.noarch
    foreman-installer-3.7.1-1.el8.noarch
    foreman-installer-katello-3.7.1-1.el8.noarch
    foreman-obsolete-packages-1.5-1.el8.noarch
    foreman-postgresql-3.7.1-1.el8.noarch
    foreman-proxy-3.7.1-1.el8.noarch
    foreman-release-3.7.1-1.el8.noarch
    foreman-selinux-3.7.1-1.el8.noarch
    foreman-service-3.7.1-1.el8.noarch
    foreman-vmware-3.7.1-1.el8.noarch
    katello-4.9.2-1.el8.noarch
    katello-certs-tools-2.9.0-2.el8.noarch
    katello-client-bootstrap-1.7.9-2.el8.noarch
    katello-common-4.9.2-1.el8.noarch
    katello-debug-4.9.2-1.el8.noarch
    katello-default-ca-1.0-1.noarch
    katello-repos-4.9.2-1.el8.noarch
    katello-selinux-5.0.2-1.el8.noarch
    katello-server-ca-1.0-1.noarch
    pulp-client-1.0-7.noarch
    pulpcore-selinux-2.0.0-1.el8.x86_64
    python2-qpid-1.37.0-1.el8.noarch
    python2-qpid-qmf-1.39.0-7.el8.x86_64
    python3-qpid-proton-0.37.0-1.el8.x86_64
    python39-pulp-ansible-0.16.0-1.el8.noarch
    python39-pulp-certguard-1.5.6-1.el8.noarch
    python39-pulp-cli-0.14.0-4.el8.noarch
    python39-pulp-container-2.14.7-1.el8.noarch
    python39-pulp-deb-2.20.4-1.el8.noarch
    python39-pulp-file-1.12.0-1.el8.noarch
    python39-pulp-python-3.8.0-1.el8.noarch
    python39-pulp-rpm-3.19.11-2.el8.noarch
    python39-pulpcore-3.22.19-1.el8.noarch
    qpid-cpp-client-1.39.0-7.el8.x86_64
    qpid-cpp-client-devel-1.39.0-7.el8.x86_64
    qpid-cpp-server-1.39.0-7.el8.x86_64
    qpid-cpp-server-linearstore-1.39.0-7.el8.x86_64
    qpid-dispatch-router-1.14.0-1.el8.x86_64
    qpid-proton-c-0.37.0-1.el8.x86_64
    qpid-qmf-1.39.0-7.el8.x86_64
    qpid-tools-1.39.0-7.el8.noarch
    qpid_router_katello_agent-qpid-router-client-1.0-1.noarch
    rubygem-foreman-tasks-8.1.4-1.fm3_7.el8.noarch
    rubygem-foreman_ansible-12.0.6-1.fm3_7.el8.noarch
    rubygem-foreman_maintain-1.3.5-1.el8.noarch
    rubygem-foreman_puppet-6.0.0-1.fm3_7.el8.noarch
    rubygem-foreman_remote_execution-10.1.2-1.fm3_7.el8.noarch
    rubygem-foreman_snapshot_management-2.0.3-1.fm3_6.el8.noarch
    rubygem-foreman_virt_who_configure-0.5.13-1.fm3_7.el8.noarch
    rubygem-foreman_vmwareannotations-0.0.1-6.fm3_3.el8.noarch
    rubygem-hammer_cli-3.7.0-1.el8.noarch
    rubygem-hammer_cli_foreman-3.7.0-1.el8.noarch
    rubygem-hammer_cli_foreman_ansible-0.5.0-1.fm3_7.el8.noarch
    rubygem-hammer_cli_foreman_bootdisk-0.3.0-3.fm3_5.el8.noarch
    rubygem-hammer_cli_foreman_puppet-0.0.6-1.fm3_4.el8.noarch
    rubygem-hammer_cli_foreman_remote_execution-0.2.3-1.fm3_7.el8.noarch
    rubygem-hammer_cli_foreman_tasks-0.0.19-1.fm3_7.el8.noarch
    rubygem-hammer_cli_foreman_virt_who_configure-0.0.9-2.fm3_5.el8.noarch
    rubygem-hammer_cli_katello-1.9.1-1.el8.noarch
    rubygem-katello-4.9.2-1.el8.noarch
    rubygem-pulp_ansible_client-0.16.1-1.el8.noarch
    rubygem-pulp_certguard_client-1.6.5-1.el8.noarch
    rubygem-pulp_container_client-2.14.5-1.el8.noarch
    rubygem-pulp_deb_client-2.20.2-1.el8.noarch
    rubygem-pulp_file_client-1.12.0-1.el8.noarch
    rubygem-pulp_ostree_client-2.0.0-1.el8.noarch
    rubygem-pulp_python_client-3.8.0-1.el8.noarch
    rubygem-pulp_rpm_client-3.19.6-1.el8.noarch
    rubygem-pulpcore_client-3.22.4-1.el8.noarch
    rubygem-qpid_proton-0.37.0-1.el8.x86_64
    rubygem-smart_proxy_pulp-3.2.0-3.fm3_3.el8.noarch

Distribution and version:
Rhel8 - 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Thu Dec 7 03:06:13 EST 2023 x86_64 x86_64 x86_64 GNU/Linux

Other relevant data:
We had the same issue in Foreman 3.3.1.
Report preview works.
In the production.log we see the following:

2024-02-08T11:43:38 [E|app|ae5f5c10] Error performing TemplateRenderJob (Job ID: 1cf8ecfc-4364-4441-ac4d-26622ab51831) from Dynflow(default) in 1008.49ms: NoMethodError (undefined method `value' for
nil:NilClass):
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:378:in `errata_ids_from_template_invocation'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:365:in `parse_errata'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:269:in `block (2 levels) in load_errata_applications'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/delegation.rb:88:in `each'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/delegation.rb:88:in `each'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:267:in `block in load_errata_applications'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches/batch_enumerator.rb:80:in `block in each'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:245:in `block in in_batches'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:229:in `loop'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:229:in `in_batches'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches/batch_enumerator.rb:80:in `each'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches/batch_enumerator.rb:80:in `each'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:261:in `load_errata_applications'
 ae5f5c10 | Host - Applied Errata:3:in `get_binding'
 ae5f5c10 | /usr/share/ruby/erb.rb:905:in `eval'
 ae5f5c10 | /usr/share/ruby/erb.rb:905:in `result'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer/unsafe_mode_renderer.rb:7:in `render'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'
 ae5f5c10 | /usr/share/foreman/app/models/template.rb:172:in `render'
 ae5f5c10 | /usr/share/foreman/app/models/report_composer.rb:241:in `render'
 ae5f5c10 | /usr/share/foreman/app/jobs/template_render_job.rb:12:in `block in perform'
 ae5f5c10 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
 ae5f5c10 | /usr/share/foreman/app/jobs/template_render_job.rb:9:in `perform'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:48:in `block in perform_now'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/i18n-1.13.0/lib/i18n.rb:322:in `with_locale'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/translation.rb:9:in `block (2 levels) in <module:Translation>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/core_ext/time/zones.rb:66:in `use_zone'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/timezones.rb:9:in `block (2 levels) in <module:Timezones>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:21:in `block in instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb:203:in `block in instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb:203:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:31:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:14:in `block (2 levels) in <module:Instrumentation>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/logging.rb:24:in `tag_logger'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/logging.rb:15:in `block (2 levels) in <module:Logging>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:137:in `run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:47:in `perform_now'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:25:in `block in execute'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/railtie.rb:47:in `block (4 levels) in <class:Railtie>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/execution_wrapper.rb:91:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/reloader.rb:72:in `block in wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/execution_wrapper.rb:91:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/reloader.rb:71:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/railtie.rb:46:in `block (3 levels) in <class:Railtie>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:137:in `run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:23:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/active_job/queue_adapter.rb:47:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:588:in `block (3 levels) in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action/progress.rb:31:in `with_progress_calculation'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action/progress.rb:17:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/load_setting_values.rb:20:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:52:in `restore_current_request_id'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:32:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/world.rb:31:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:587:in `block (2 levels) in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:586:in `catch'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:586:in `block in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `block in with_error_handling'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `catch'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `with_error_handling'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:581:in `execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:302:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:18:in `block (2 levels) in execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract.rb:167:in `with_meta_calculation'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block in execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:32:in `open_action'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/director.rb:69:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:11:in `block (2 levels) in perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors.rb:18:in `run_user_code'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:9:in `block in perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:25:in `with_telemetry'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:8:in `perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/serialization.rb:27:in `perform'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:196:in `execute_job'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:164:in `block (2 levels) in process'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/middleware/chain.rb:133:in `invoke'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:163:in `block in process'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/job_retry.rb:112:in `local'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq.rb:39:in `block in <module:Sidekiq>'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:257:in `stats'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/job_logger.rb:13:in `call'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/job_retry.rb:79:in `global'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:124:in `block in dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/logger.rb:11:in `with'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/job_logger.rb:33:in `prepare'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:123:in `dispatch'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:162:in `process'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:78:in `process_one'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/processor.rb:68:in `run'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/util.rb:43:in `watchdog'
 ae5f5c10 | /usr/share/gems/gems/sidekiq-6.3.1/lib/sidekiq/util.rb:52:in `block in safe_thread'
 ae5f5c10 | /usr/share/gems/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2024-02-08T11:43:38 [E|bac|ae5f5c10] undefined method `value' for nil:NilClass (NoMethodError)
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:378:in `errata_ids_from_template_invocation'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:365:in `parse_errata'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:269:in `block (2 levels) in load_errata_applications'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/delegation.rb:88:in `each'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:267:in `block in load_errata_applications'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches/batch_enumerator.rb:80:in `block in each'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:245:in `block in in_batches'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:229:in `loop'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches.rb:229:in `in_batches'
 ae5f5c10 | /usr/share/gems/gems/activerecord-6.1.7.6/lib/active_record/relation/batches/batch_enumerator.rb:80:in `each'
 ae5f5c10 | /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb:261:in `load_errata_applications'
 ae5f5c10 | Host - Applied Errata:3:in `get_binding'
 ae5f5c10 | /usr/share/ruby/erb.rb:905:in `eval'
 ae5f5c10 | /usr/share/ruby/erb.rb:905:in `result'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer/unsafe_mode_renderer.rb:7:in `render'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer/base_renderer.rb:18:in `render'
 ae5f5c10 | /usr/share/foreman/app/services/foreman/renderer.rb:46:in `render'
 ae5f5c10 | /usr/share/foreman/app/models/template.rb:172:in `render'
 ae5f5c10 | /usr/share/foreman/app/models/report_composer.rb:241:in `render'
 ae5f5c10 | /usr/share/foreman/app/jobs/template_render_job.rb:12:in `block in perform'
 ae5f5c10 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:108:in `as'
 ae5f5c10 | /usr/share/foreman/app/jobs/template_render_job.rb:9:in `perform'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:48:in `block in perform_now'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/i18n-1.13.0/lib/i18n.rb:322:in `with_locale'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/translation.rb:9:in `block (2 levels) in <module:Translation>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/core_ext/time/zones.rb:66:in `use_zone'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/timezones.rb:9:in `block (2 levels) in <module:Timezones>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:21:in `block in instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb:203:in `block in instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/notifications.rb:203:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:31:in `instrument'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/instrumentation.rb:14:in `block (2 levels) in <module:Instrumentation>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/logging.rb:24:in `tag_logger'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/logging.rb:15:in `block (2 levels) in <module:Logging>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:137:in `run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:47:in `perform_now'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:25:in `block in execute'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/railtie.rb:47:in `block (4 levels) in <class:Railtie>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/execution_wrapper.rb:91:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/reloader.rb:72:in `block in wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/execution_wrapper.rb:91:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/reloader.rb:71:in `wrap'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/railtie.rb:46:in `block (3 levels) in <class:Railtie>'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `instance_exec'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:137:in `run_callbacks'
 ae5f5c10 | /usr/share/gems/gems/activejob-6.1.7.6/lib/active_job/execution.rb:23:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/active_job/queue_adapter.rb:47:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:588:in `block (3 levels) in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action/progress.rb:31:in `with_progress_calculation'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action/progress.rb:17:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/load_setting_values.rb:20:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:52:in `restore_current_request_id'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_request_id.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_timezone.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:32:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware.rb:19:in `pass'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
 ae5f5c10 | /usr/share/gems/gems/foreman-tasks-8.1.4/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/stack.rb:23:in `call'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/middleware/world.rb:31:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:587:in `block (2 levels) in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:586:in `catch'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:586:in `block in execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `block in with_error_handling'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `catch'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:489:in `with_error_handling'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:581:in `execute_run'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/action.rb:302:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:18:in `block (2 levels) in execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract.rb:167:in `with_meta_calculation'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block in execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:32:in `open_action'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/director.rb:69:in `execute'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:11:in `block (2 levels) in perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors.rb:18:in `run_user_code'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:9:in `block in perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:25:in `with_telemetry'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:8:in `perform'
 ae5f5c10 | /usr/share/gems/gems/dynflow-1.7.0/lib/dynflow/executors/sidekiq/serialization.rb:27:in `perform'
 ae5f5c10 | [ sidekiq ]
 ae5f5c10 | [ concurrent-ruby ]

We managed to overcome this issue modifying the file /usr/share/gems/gems/katello-4.9.2/app/lib/katello/concerns/base_template_scope_extensions.rb
In function errata_ids_from_template_invocation
editing line 377-378
from:

	TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation_id, 'errata')
 .first.value.split(',')

to:

	(TemplateInvocationInputValue.joins(:template_input).where("template_invocation_id = ? AND template_inputs.name = ?", task.template_invocation_id, 'errata')
 .first&.value || "").split(',')

But we do not know if this actually fixes the issue or simply hide corrupt or missing data in the DB.
Is there a way to debug and to understand what is generating the error?

Regards,
Fabio

This looks like Bug #36811: Applied Errata report download fails with undefined method `value' for nil:NilClass error - Katello - Foreman which is fixed in Katello 4.11.0. It is caused when the Template Invocation input or the value itself is null. You may have an old “Apply errata” task that was run without a value for “errata”.