That looks exactly as the issue I had on older version with deb repositories. The patches are in katello 4.5. If you’ve upgraded from older version like 3.18 and only now are trying to use katello:delete_orphaned_content, then it may be the same issue.
To fix the repositories, I had to delete them and recreate them. Then katello:delete_orphaned_content started working without errors.