Bug #33940
closedError Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup' when clicking on "Errata Installation" inside a host_collection as a non-admin user
Description
Description of problem:
When accessing satellite as a non-admin user with custom roles configured, Host --> Host Collections --> Click on "Errata Installation" and it will show "There are no Errata associated with this Content Host to display."
And it will log the following error in the logs.
~
ActiveRecord::ConfigurationError: Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup'; perhaps you misspelled it?
~
How reproducible:
Always
Steps to Reproduce:
1. Register a host and ensure it has some installable updates available.
2. Associate the host with a hostgroup named "Test" and host_collection name "Patch"
3. Create a custom role with following permissions and filters.
~~
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
ID | RESOURCE TYPE | SEARCH | UNLIMITED? | OVERRIDE? | ROLE | PERMISSIONS
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
350 | Host | hostgroup = Test | no | no | ospatch | view_hosts, edit_hosts
351 | Katello::HostCollection | none | no | no | ospatch | view_host_collections, create_host_collections, edit_host_collections, destro...
357 | Hostgroup | name = Test | no | no | ospatch | view_hostgroups, destroy_hostgroups
----|-------------------------|------------------|------------|-----------|---------|---------------------------------------------------------------------------------
~~
4. Create a user called "Patch-Admin" and add the role "ospatch" to that user.
5. Login as "Patch-Admin" user and access Host --> Host Collections --> Patch --> Click on "Errata Installation"
Actual results:
In GUI --> "There are no Errata associated with this Content Host to display."
In production.log
~~
2021-06-11T00:14:26 [I|app|39d0c057] Started POST "/api/v2/hosts/bulk/installable_errata" for 10.74.X.X at 2021-06-11 00:14:26 +0530
2021-06-11T00:14:26 [I|app|39d0c057] Processing by Katello::Api::V2::HostsBulkActionsController#installable_errata as HTML
2021-06-11T00:14:26 [I|app|39d0c057] Parameters: {"included"=>{"search"=>"host_collection_id = 1", "ids"=>[2]}, "paged"=>true, "page"=>"1", "per_page"=>"20", "search"=>"", "organization_id"=>"1", "api_version"=>"v2", "hosts_bulk_action"=>{"included"=>{"search"=>"host_collection_id = 1", "ids"=>[2]}, "paged"=>true, "page"=>"1", "per_page"=>"20", "search"=>"", "organization_id"=>"1"}}
2021-11-17T00:03:33 [E|app|f5539fce] ActiveRecord::ConfigurationError: Can't join 'Katello::ContentFacetRepository' to association named 'hostgroup'; perhaps you misspelled it?
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:201:in `find_reflection'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:206:in `block in build'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:205:in `each'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:205:in `map'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:205:in `build'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/associations/join_dependency.rb:69:in `initialize'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:1020:in `new'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:1020:in `construct_join_dependency'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/finder_methods.rb:373:in `apply_join_dependency'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder/relation_handler.rb:8:in `call'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:55:in `build'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:109:in `block in expand_from_hash'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `each'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `flat_map'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `expand_from_hash'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:70:in `block in expand_from_hash'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `each'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `flat_map'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:68:in `expand_from_hash'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/predicate_builder.rb:21:in `build_from_hash'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/where_clause_factory.rb:19:in `build'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:656:in `where!'
f5539fce | /home/vagrant/foreman/.vendor/ruby/2.7.0/gems/activerecord-6.0.3.7/lib/active_record/relation/query_methods.rb:649:in `where'
f5539fce | /home/vagrant/katello/app/models/katello/concerns/pulp_database_unit.rb:103:in `installable_for_hosts'
f5539fce | /home/vagrant/katello/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb:115:in `installable_errata'
Expected results:
It should show the available errata's to install.
Updated by The Foreman Bot about 3 years ago
- Status changed from New to Ready For Testing
- Assignee set to Partha Aji
- Pull request https://github.com/Katello/katello/pull/9792 added
Updated by The Foreman Bot about 3 years ago
- Fixed in Releases Katello 4.4.0 added
Updated by Partha Aji about 3 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|276371854df4323200b9b9414a9f7fea36fe5162.