Bug #32179
closedHTTP 500 returned if trying to download a subnet bootdisk for non-existent subnet id
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1879020
Description of problem:
The request returns 500 instead of 404 if a non-existent subnet id is provided.
- hammer bootdisk subnet --subnet-id 999
Failed to download subnet disk image:
500 Internal Server Error
2020-09-15T04:35:27 [I|app|b2d506db] Started GET "/bootdisk/api/subnets/2" for 2620:52:0:10d8:7ae7:d1ff:fe21:6e78 at 2020-09-15 04:35:27 -0400
2020-09-15T04:35:27 [I|app|b2d506db] Processing by ForemanBootdisk::Api::V2::SubnetDisksController#subnet as JSON
2020-09-15T04:35:27 [I|app|b2d506db] Parameters: {"apiv"=>"v2", "id"=>"2", "subnet_disk"=>{}}
2020-09-15T04:35:28 [D|app|b2d506db] Authenticated user admin against INTERNAL authentication source
2020-09-15T04:35:28 [D|app|b2d506db] Post-login processing for admin
2020-09-15T04:35:28 [I|app|b2d506db] Authorized user admin(Admin User)
2020-09-15T04:35:28 [D|app|b2d506db] Post-login processing for admin
2020-09-15T04:35:28 [D|tax|b2d506db] Current location set to none
2020-09-15T04:35:28 [D|tax|b2d506db] Current organization set to none
2020-09-15T04:35:28 [D|tax|b2d506db] Current location set to none
2020-09-15T04:35:28 [D|tax|b2d506db] Current organization set to none
2020-09-15T04:35:28 [I|app|b2d506db] Couldn't find Subnet with 'id'=2 (ActiveRecord::RecordNotFound)
2020-09-15T04:35:28 [I|app|b2d506db] Completed 500 Internal Server Error in 121ms (ActiveRecord: 42.4ms | Allocations: 10166)
2020-09-15T04:35:28 [F|app|b2d506db]
NameError (Could not find resource class for resource subnet_disk):
How reproducible:
using hammer and api
Steps to Reproduce:
1. try to download a subnet disk image for a non-existent subnet, e.g. # hammer bootdisk subnet --subnet-id 9999
Actual results:
HTTP 500 returned
Expected results:
HTTP 404 returned with a proper error message