Description of problem:
When there is HW model created and a host is created with the associated HW model and you then try to delete this HW model via UI, deletion fails (as it should), but there is also just an error message containing
"Request failed with status code 422"
there should be this error message,
"HW_MODEL_NAME is used by HOST.COM"
which can also be seen in the production log below.
2025-10-01T03:26:58 [I|app|ccc5af71] Started DELETE "/api/models/3" for 10.44.32.160 at 2025-10-01 03:26:58 -0400
2025-10-01T03:26:58 [I|app|ccc5af71] Processing by Api::V2::ModelsController#destroy as JSON
2025-10-01T03:26:58 [I|app|ccc5af71] Parameters: {"apiv"=>"v2", "id"=>"3"}
2025-10-01T03:26:58 [I|aud|ccc5af71] Model (3) destroy event on name MUeMiOgiOo
2025-10-01T03:26:58 [I|aud|ccc5af71] Model (3) destroy event on info JdfHCwEBiU
2025-10-01T03:26:58 [I|aud|ccc5af71] Model (3) destroy event on vendor_class vPkbuQqxUg
2025-10-01T03:26:58 [I|aud|ccc5af71] Model (3) destroy event on hardware_model zWpdDqE2a2
2025-10-01T03:26:58 [E|app|ccc5af71] You may not destroy MUeMiOgiOo as it is in use!
2025-10-01T03:26:58 [E|app|ccc5af71] Unprocessable entity Model (id: 3):
ccc5af71 | MUeMiOgiOo is used by ijbfrczhhj.skiluk2sxo
ccc5af71 |
2025-10-01T03:26:58 [I|app|ccc5af71] Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (Duration: 0.9ms | Allocat
ions: 442)
2025-10-01T03:26:58 [I|app|ccc5af71] Rendered layout api/v2/layouts/error_layout.json.erb (Duration: 1.3ms | Allocations: 700)
2025-10-01T03:26:58 [I|app|ccc5af71] Completed 422 Unprocessable Entity in 30ms (Views: 5.5ms | ActiveRecord: 4.5ms | Allocations: 11093)
2025-10-01T03:27:08 [I|app|a5d3925b] Started GET "/notification_recipients" for 10.44.32.160 at 2025-10-01 03:27:08 -0400
2025-10-01T03:27:08 [I|app|a5d3925b] Processing by NotificationRecipientsController#index as JSON
2025-10-01T03:27:08 [I|app|a5d3925b] Completed 200 OK in 7ms (Views: 0.1ms | ActiveRecord: 1.0ms | Allocations: 2320)
How reproducible:
100%
Is this issue a regression from an earlier version:
No
Steps to Reproduce:
1. Create HW model
2. Create host associated with the HW model
3. Try to delete HW model
4. Observe UI error message
Actual behavior:
Deletion of the associated HW model fails with a plain 422 error in the Satellite UI
Expected behavior:
Deletion of the associated HW model fails with a more descriptive error in the Satellite UI.
Something like Cannot delete HW_MODEL_NAME, it is used by HOST.COM
Business Impact / Additional info:
Found during TFA of tests/foreman/ui/test_hardwaremodel.py::test_positive_end_to_end
STREAM 134
satellite-6.19.0-0.1.stream.el9sat.noarch
foreman-3.17.0-0.1.develop.20250925004602gita271812.el9sat.noarch
katello-4.19.0-0.1.master.el9sat.noarch
rubygem-hammer_cli_foreman_rh_cloud-1.0.5-1.el9sat.noarch
rubygem-foreman_rh_cloud-13.0.4-1.el9sat.noarch
rubygem-foreman_theme_satellite-15.3.2-1.el9sat.noarch
Red Hat Enterprise Linux release 9.6 (Plow)