return api error when device doesn't exist (#12978)

* return api error when device doesn't exist

Function device_by_id_cache returns a hash table, which isn't null despite the device not existing.  This checks to see if the type has been populated to also determine if the device exists. 

Without this, the function always returns a "valid" device, even if one doesn't exist.

* use device_id instead of type
This commit is contained in:
VTS 2021-06-24 18:13:51 -04:00 committed by GitHub
parent 03aa453893
commit b6f9dd29df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -266,7 +266,7 @@ function get_device(Illuminate\Http\Request $request)
// find device matching the id
$device = device_by_id_cache($device_id);
if (! $device) {
if (! $device || ! $device['device_id']) {
return api_error(404, "Device $hostname does not exist");
}