Bug #39599
closedHammer host create/update validation for non-existent content-source-id is missing
Description
Description of problem:
Hammer host create command with a non-existent --content-source-id succeeds silently instead of returning an error.
The same applies to host update — updating a host with a bogus --content-source-id does not raise an error and sets the content source to None. (In this case, it should keep the same content source as it was before the update)
How reproducible:
100%
Is this issue a regression from an earlier version:
Yes.
This is a regression likely introduced by Katello/katello#11753 ("Fixes #39330 - Remove deprecated CV/LCE params from hosts, AKs, hostgroups"), merged 2026-05-28.
AI analysis:
The PR removed attributes= and update method overrides along with check_cve_attributes from app/models/katello/concerns/host_managed_extensions.rb
The content_source_id validation was collateral damage — it was lost along with the deprecated CV/LCE parameter handling.
Steps to Reproduce:
Run hammer host create/update with a non-existent --content-source-id:
Example command create:
hammer host create --name="test-host" --content-source-id="99999" --content-view-environments="Library/<cv_label>" --organization="<org>" --location-id="2" --domain-id="<id>"
--architecture-id="1" --operatingsystem-id="<id>" --partition-table-id="<id>" --medium-id="<id>" --root-password="changeme" --ip="1.2.3.4" --mac="aa:bb:cc:dd:ee:ff"
Observe that the host is created without error.
Run hammer host info --name="test-host" and check the content source — it will be empty/None.
Actual behavior:
The host is created successfully with a non-existent content-source-id. No error is returned.
Similarly, hammer host update --id=<id> --content-source-id=99999 succeeds silently and sets the content source to None.
Expected behavior:
Hammer should return an error when --content-source-id references a non-existent smart proxy, both on create and update.
In 6.19 create action with invalid content-source-id fails with:
2026-07-07T06:52:10 [I|app|ba45c6cf] Started POST "/api/hosts" for 10.0.198.218 at 2026-07-07 06:52:10 -0400
2026-07-07T06:52:10 [I|app|ba45c6cf] Processing by Api::V2::HostsController#create as JSON
2026-07-07T06:52:10 [I|app|ba45c6cf] Parameters: {"location_id"=>2, "organization_id"=>6, "host"=>{"name"=>"ttHyniOCyS", "location_id"=>2, "organization_id"=>6, "ip"=>"5.67.220.146", "mac"=>"ee:e0:44:49:56:10", "architecture_id"=>1, "domain_id"=>4, "operatingsystem_id"=>3, "medium_id"=>"17", "ptable_id"=>254, "content_facet_attributes"=>{"content_view_id"=>9, "lifecycle_environment_id"=>5, "content_source_id"=>75615}, "subscription_facet_attributes"=>{}, "overwrite"=>true, "build"=>true, "managed"=>true, "enabled"=>true, "compute_attributes"=>{"volumes_attributes"=>{}}, "interfaces_attributes"=>[], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"}
2026-07-07T06:52:10 [I|app|ba45c6cf] Authorized user admin(Admin User)
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Discovery reboot: Content source with given ID not found
2026-07-07T06:52:10 [E|app|ba45c6cf] Unprocessable entity Host::Managed (id: new):
ba45c6cf | Content source with given ID not found
ba45c6cf |
2026-07-07T06:52:10 [I|app|ba45c6cf] Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (Duration: 2.4ms | Allocations: 705)
2026-07-07T06:52:10 [I|app|ba45c6cf] Rendered layout api/v2/layouts/error_layout.json.erb (Duration: 2.9ms | Allocations: 961)
2026-07-07T06:52:10 [I|app|ba45c6cf] Completed 422 Unprocessable Entity in 211ms (Views: 7.0ms | ActiveRecord: 19.9ms | Allocations: 77325)
Business Impact / Additional info:
Found in snap 196 by automation:
test_negative_create_with_content_source https://github.com/SatelliteQE/robottelo/blob/478b161f9b1145e25c86a818d0c9fc9069c3f8d5/tests/foreman/cli/test_host.py#L461 & test_negative_update_content_source https://github.com/SatelliteQE/robottelo/blob/478b161f9b1145e25c86a818d0c9fc9069c3f8d5/tests/foreman/cli/test_host.py#L485
in tests/foreman/cli/test_host.py
Failing consistently in Jenkins job proton/rpm/ipv4/sat-stream-rhel9-Hosts since snap 195.0 (build 79).
satellite-6.20.0-0.3.stream.el9sat.noarch
foreman-5.0.0-0.2.develop.20260630005219git6ff74f5.el9sat.noarch
katello-5.0.0-0.1.master.el9sat.noarch
rubygem-hammer_cli_foreman_rh_cloud-1.0.7-1.el9sat.noarch
rubygem-foreman_rh_cloud-14.2.1-1.el9sat.noarch
rubygem-foreman_theme_satellite-16.3.0-1.el9sat.noarch
Red Hat Enterprise Linux release 9.8 (Plow)
Updated by Ladislav Vašina 2 months ago
- Project changed from Hammer CLI to Katello
Description of problem:
Hammer host create command with a non-existent --content-source-id succeeds silently instead of returning an error.
The same applies to host update — updating a host with a bogus --content-source-id does not raise an error and sets the content source to None. (In this case, it should keep the same content source as it was before the update)
How reproducible:
100%
Is this issue a regression from an earlier version:
Yes.
This is a regression likely introduced by Katello/katello#11753 ("Fixes #39330 - Remove deprecated CV/LCE params from hosts, AKs, hostgroups"), merged 2026-05-28.
AI analysis:
The PR removed attributes= and update method overrides along with check_cve_attributes from app/models/katello/concerns/host_managed_extensions.rb
The content_source_id validation was collateral damage — it was lost along with the deprecated CV/LCE parameter handling.
Steps to Reproduce:
Run hammer host create/update with a non-existent --content-source-id:
Example command create:
hammer host create --name="test-host" --content-source-id="99999" --content-view-environments="Library/<cv_label>" --organization="<org>" --location-id="2" --domain-id="<id>"
--architecture-id="1" --operatingsystem-id="<id>" --partition-table-id="<id>" --medium-id="<id>" --root-password="changeme" --ip="1.2.3.4" --mac="aa:bb:cc:dd:ee:ff"
Observe that the host is created without error.
Run hammer host info --name="test-host" and check the content source — it will be empty/None.
Actual behavior:
The host is created successfully with a non-existent content-source-id. No error is returned.
Similarly, hammer host update --id=<id> --content-source-id=99999 succeeds silently and sets the content source to None.
Expected behavior:
Hammer should return an error when --content-source-id references a non-existent smart proxy, both on create and update.
In 6.19 create action with invalid content-source-id fails with:
2026-07-07T06:52:10 [I|app|ba45c6cf] Started POST "/api/hosts" for 10.0.198.218 at 2026-07-07 06:52:10 -0400
2026-07-07T06:52:10 [I|app|ba45c6cf] Processing by Api::V2::HostsController#create as JSON
2026-07-07T06:52:10 [I|app|ba45c6cf] Parameters: {"location_id"=>2, "organization_id"=>6, "host"=>{"name"=>"ttHyniOCyS", "location_id"=>2, "organization_id"=>6, "ip"=>"5.67.220.146", "mac"=>"ee:e0:44:49:56:10", "architecture_id"=>1, "domain_id"=>4, "operatingsystem_id"=>3, "medium_id"=>"17", "ptable_id"=>254, "content_facet_attributes"=>{"content_view_id"=>9, "lifecycle_environment_id"=>5, "content_source_id"=>75615}, "subscription_facet_attributes"=>{}, "overwrite"=>true, "build"=>true, "managed"=>true, "enabled"=>true, "compute_attributes"=>{"volumes_attributes"=>{}}, "interfaces_attributes"=>[], "root_pass"=>"[FILTERED]"}, "apiv"=>"v2"}
2026-07-07T06:52:10 [I|app|ba45c6cf] Authorized user admin(Admin User)
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Host::Managed: ["Content source with given ID not found"]
2026-07-07T06:52:10 [W|app|ba45c6cf] Not queueing Discovery reboot: Content source with given ID not found
2026-07-07T06:52:10 [E|app|ba45c6cf] Unprocessable entity Host::Managed (id: new):
ba45c6cf | Content source with given ID not found
ba45c6cf |
2026-07-07T06:52:10 [I|app|ba45c6cf] Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (Duration: 2.4ms | Allocations: 705)
2026-07-07T06:52:10 [I|app|ba45c6cf] Rendered layout api/v2/layouts/error_layout.json.erb (Duration: 2.9ms | Allocations: 961)
2026-07-07T06:52:10 [I|app|ba45c6cf] Completed 422 Unprocessable Entity in 211ms (Views: 7.0ms | ActiveRecord: 19.9ms | Allocations: 77325)
Business Impact / Additional info:
Found in snap 196 by automation:
test_negative_create_with_content_source https://github.com/SatelliteQE/robottelo/blob/478b161f9b1145e25c86a818d0c9fc9069c3f8d5/tests/foreman/cli/test_host.py#L461 & test_negative_update_content_source https://github.com/SatelliteQE/robottelo/blob/478b161f9b1145e25c86a818d0c9fc9069c3f8d5/tests/foreman/cli/test_host.py#L485
in tests/foreman/cli/test_host.py
Failing consistently in Jenkins job proton/rpm/ipv4/sat-stream-rhel9-Hosts since snap 195.0 (build 79).
satellite-6.20.0-0.3.stream.el9sat.noarch
foreman-5.0.0-0.2.develop.20260630005219git6ff74f5.el9sat.noarch
katello-5.0.0-0.1.master.el9sat.noarch
rubygem-hammer_cli_foreman_rh_cloud-1.0.7-1.el9sat.noarch
rubygem-foreman_rh_cloud-14.2.1-1.el9sat.noarch
rubygem-foreman_theme_satellite-16.3.0-1.el9sat.noarch
Red Hat Enterprise Linux release 9.8 (Plow)
Updated by The Foreman Bot 2 months ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/11829 added
Updated by Ian Ballou 2 months ago
- Category set to Hosts
- Target version set to Katello 5.0.0
- Triaged changed from No to Yes
Updated by The Foreman Bot about 2 months ago
- Fixed in Releases Katello 5.1.0 added
Updated by Anonymous about 2 months ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|bce255c5a5193c79c4cb5fc861d4fe1e7f1d6e02.
Updated by The Foreman Bot about 2 months ago
- Fixed in Releases Katello 5.0.1 added