Bug 2224719

Summary: Actions::ForemanLeapp::PreupgradeJob fails with null value in column "preupgrade_report_id" violates not-null constraint when run with non-admin user
Product: Red Hat Satellite Reporter: Jan Jansky <jjansky>
Component: Leapp integrationAssignee: satellite6-bugs <satellite6-bugs>
Status: NEW --- QA Contact: visawant
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.13.2CC: ahumbe, aruzicka, lstejska, pwaghmar, rlavi, visawant
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: 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 Jan Jansky 2023-07-22 13:04:23 UTC
Description of problem:
Execution of Actions::ForemanLeapp::PreupgradeJob job will always fail when run as non-admin user (tested with Organization Admin role) with error below

PG::NotNullViolation: ERROR:  null value in column "preupgrade_report_id" violates not-null constraint

Version-Release number of selected component (if applicable):
Satellite 6.13.2 - rubygem-foreman_leapp-0.1.10-2.1.el8sat.noarch
Satellite 6.12.4 - rubygem-foreman_leapp-0.1.10-2.1.el8sat.noarch

How reproducible:
Always

Steps to Reproduce:
1. Create user with "Organization admin" role
2. With this user execute PreUpgrade Leapp job on some hosts

Actual results:
Always fail with below

2023-07-22T14:49:59 [E|bac|ba9eda6c] PG::NotNullViolation: ERROR:  null value in column "preupgrade_report_id" violates not-null constraint
 ba9eda6c | DETAIL:  Failing row contains (39, null, jjansky-rhel7.sat612.jjansky.lan, Automatic registration into Red Hat Insights, check_insights_auto_register, sysadmin, info, 84b9e368-10f4-4411-9697-5b04ba3dbaee, After the upgrade, this system will be automatically registered ..., ---
 ba9eda6c | - services
 ba9eda6c | , null, 2023-07-22 12:49:59.308917, 2023-07-22 12:49:59.308917, 4, null).
 ba9eda6c |  (ActiveRecord::NotNullViolation)
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `exec_params'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block (2 levels) in exec_no_cache'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `block in exec_no_cache'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract_adapter.rb:728:in `block (2 levels) in log'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract_adapter.rb:727:in `block in log'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract_adapter.rb:718:in `log'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:673:in `exec_no_cache'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql_adapter.rb:656:in `execute_and_clear'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `exec_query'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:135:in `exec_insert'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/postgresql/database_statements.rb:132:in `exec_insert'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:166:in `insert'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/query_cache.rb:22:in `insert'
ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/persistence.rb:375:in `_insert_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/persistence.rb:932:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/counter_cache.rb:166:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/locking/optimistic.rb:79:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/attribute_methods/dirty.rb:211:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/callbacks.rb:331:in `block in _create_record'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/callbacks.rb:101:in `run_callbacks'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/callbacks.rb:825:in `_run_create_callbacks'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/callbacks.rb:331:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/timestamp.rb:110:in `_create_record'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/persistence.rb:905:in `create_or_update'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/callbacks.rb:327:in `block in create_or_update'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/callbacks.rb:135:in `run_callbacks'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/callbacks.rb:825:in `_run_save_callbacks'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/callbacks.rb:327:in `create_or_update'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/timestamp.rb:128:in `create_or_update'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/persistence.rb:503:in `save!'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/validations.rb:53:in `save!'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/transactions.rb:318:in `block in save!'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/transactions.rb:212:in `transaction'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/transactions.rb:318:in `save!'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/suppressor.rb:48:in `save!'
 ba9eda6c | /usr/share/gems/gems/activerecord-6.0.6/lib/active_record/persistence.rb:55:in `create!'
 ba9eda6c | /usr/share/gems/gems/foreman_leapp-0.1.10/app/models/preupgrade_report.rb:15:in `block in create_report'
 ba9eda6c | /usr/share/gems/gems/foreman_leapp-0.1.10/app/models/preupgrade_report.rb:14:in `each'
 ba9eda6c | /usr/share/gems/gems/foreman_leapp-0.1.10/app/models/preupgrade_report.rb:14:in `create_report'
 ba9eda6c | /usr/share/gems/gems/foreman_leapp-0.1.10/app/lib/actions/preupgrade_job.rb:21:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:604:in `block (2 levels) in execute_finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/rails_executor_wrap.rb:20:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/activesupport-6.0.6/lib/active_support/execution_wrapper.rb:91:in `wrap'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/rails_executor_wrap.rb:19:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action/progress.rb:31:in `with_progress_calculation'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action/progress.rb:23:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/load_setting_values.rb:25:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_request_id.rb:19:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_request_id.rb:52:in `restore_current_request_id'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_request_id.rb:19:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_timezone.rb:19:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_timezone.rb:19:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_taxonomies.rb:19:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_taxonomies.rb:19:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:40:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:25:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:25:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/world.rb:31:in `execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:603:in `block in execute_finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:483:in `block in with_error_handling'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:483:in `catch'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:483:in `with_error_handling'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:602:in `execute_finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/action.rb:296:in `execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:18:in `block (2 levels) in execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/execution_plan/steps/abstract.rb:167:in `with_meta_calculation'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block in execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:32:in `open_action'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `execute'
ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:78:in `run_step'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:63:in `dispatch'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:70:in `block in run_in_sequence'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:70:in `all?'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:70:in `run_in_sequence'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:59:in `dispatch'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:28:in `block in finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:29:in `block in finalize_phase'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
 ba9eda6c | /usr/share/gems/gems/foreman-tasks-6.0.3/app/lib/actions/middleware/keep_current_user.rb:29:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:27:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:19:in `pass'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware.rb:48:in `finalize_phase'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/stack.rb:23:in `call'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/middleware/world.rb:31:in `execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director/sequential_manager.rb:27:in `finalize'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/director.rb:143:in `execute'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors/sidekiq/worker_jobs.rb:11:in `block (2 levels) in perform'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors.rb:18:in `run_user_code'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors/sidekiq/worker_jobs.rb:9:in `block in perform'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors/sidekiq/worker_jobs.rb:25:in `with_telemetry'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors/sidekiq/worker_jobs.rb:8:in `perform'
 ba9eda6c | /usr/share/gems/gems/dynflow-1.6.10/lib/dynflow/executors/sidekiq/serialization.rb:27:in `perform'
 ba9eda6c | [ sidekiq ]
 ba9eda6c | [ concurrent-ruby ]
2023-07-22T14:49:59 [D|dyn|ba9eda6c]          Step 9040b002-1070-4c28-88d3-2b25cae1d4b1: 6   running >>     error in phase Finalize Actions::ForemanLeapp::PreupgradeJob
2023-07-22T14:49:59 [D|dyn|] ExecutionPlan 9040b002-1070-4c28-88d3-2b25cae1d4b1      running >>   stopped
2023-07-22T14:49:59 [D|tax|] Current organization set to JJAN_ORG
2023-07-22T14:49:59 [D|tax|] Current location set to BRQ
2023-07-22T14:49:59 [I|bac|ba9eda6c] Task {label: Actions::RemoteExecution::RunHostJob, id: b1aa4518-e7f8-4513-8ed8-6043e9963f1e, execution_plan_id: 9040b002-1070-4c28-88d3-2b25cae1d4b1} state changed: stopped  result: error

Expected results:
Record correctly saved in Database same as with "Admin" user

Additional info:
Even with debug logs do not see any missing permissions.
Reproducer details in private message