Proxy sync content fails with: bad argument (expected URI object or URI string)

Problem:
Sync to smart proxy error: bad argument (expected URI object or URI string) (ArgumentError)

Foreman and Proxy versions:
Foreman:
version: 3.0.1
Features: Puppet CA, Puppet, Logs, Registration, and Pulpcore

Proxy:
version: 3.0.1
Features: Pulpcore, Logs, and Registration

Distribution and version:
CentOS Linux release 7.9.2009 (Core)

Other relevant data:
production.log:

2022-01-07T09:09:07 [E|bac|b3deecd6] bad argument (expected URI object or URI string) (ArgumentError)
 b3deecd6 | /opt/rh/rh-ruby27/root/usr/share/ruby/uri/common.rb:739:in `URI'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/services/katello/pulp3/repository/yum.rb:15:in `remote_options'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/services/katello/pulp3/repository.rb:197:in `compute_remote_options'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/services/katello/pulp3/repository_mirror.rb:37:in `needs_updates?'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/services/katello/pulp3/repository.rb:167:in `mirror_needs_updates?'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/katello/capsule_content/refresh_repos.rb:43:in `block in invoke_external_task'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/relation/delegation.rb:87:in `each'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/katello/capsule_content/refresh_repos.rb:37:in `invoke_external_task'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action/polling.rb:84:in `initiate_external_action'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action/polling.rb:19:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action/cancellable.rb:14:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/pulp3/abstract_async_task.rb:10:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:572:in `block (3 levels) in execute_run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:32:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/middleware/remote_action.rb:16:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/middleware/remote_action.rb:40:in `block in as_remote_user'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/models/katello/concerns/user_extensions.rb:21:in `cp_config'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/middleware/remote_action.rb:27:in `as_cp_user'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/middleware/remote_action.rb:39:in `as_remote_user'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.2.1/app/lib/actions/middleware/remote_action.rb:16:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/rails_executor_wrap.rb:14:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/execution_wrapper.rb:88:in `wrap'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/rails_executor_wrap.rb:13:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action/progress.rb:31:in `with_progress_calculation'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action/progress.rb:17:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/load_setting_values.rb:20:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_request_id.rb:15:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_request_id.rb:52:in `restore_current_request_id'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_request_id.rb:15:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_timezone.rb:15:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_timezone.rb:15:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:32:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:27:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware.rb:19:in `pass'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-5.1.0/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/stack.rb:23:in `call'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/middleware/world.rb:31:in `execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:571:in `block (2 levels) in execute_run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:570:in `catch'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:570:in `block in execute_run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:473:in `block in with_error_handling'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:473:in `catch'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:473:in `with_error_handling'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:565:in `execute_run'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/action.rb:286:in `execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:18:in `block (2 levels) in execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan/steps/abstract.rb:167:in `with_meta_calculation'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block in execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:32:in `open_action'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/director.rb:69:in `execute'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:11:in `block (2 levels) in perform'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors.rb:18:in `run_user_code'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:9:in `block in perform'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:25:in `with_telemetry'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors/sidekiq/worker_jobs.rb:8:in `perform'
 b3deecd6 | /opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.5.0/lib/dynflow/executors/sidekiq/serialization.rb:27:in `perform'
 b3deecd6 | [ sidekiq ]
 b3deecd6 | [ concurrent-ruby ]
su - postgres -c "psql foreman -c \"select id, name, url, download_policy from katello_root_repositories where url is NULL;\""
 id |      name       | url | download_policy
----+-----------------+-----+-----------------
  1 | CentOS 7 OwnRepo |     | on_demand
  6 | CentOS 8 OwnRepo |     | on_demand

These repositories are only package uploads, no upstream url.

@sajha , Who could look into this issue?

@cave : Thanks for raising this. This issue should be fixed by the changes introduced here: Fixes #33893 - fix smart proxy sync with blank url by jlsherrill · Pull Request #9775 · Katello/katello · GitHub and that should land in 4.2.2. I am not sure if 4.2.2 is out yet.

Hi @sajha ,

Thanks for the update. I look forward to update katello when it’s available.

Kind regards

Upgrading to 4.2.2 did solve the issue.