From bf19d03ee5f9e88a5c614cd60e51be02ff23b17d Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Sat, 30 Sep 2023 01:12:35 -0400 Subject: [PATCH] fix(striker-ui): correct response status when no records in fetch anvil cpu --- .../src/lib/request_handlers/anvil/getAnvilCpu.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts index 6cf35000..2a1bace2 100644 --- a/striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts +++ b/striker-ui-api/src/lib/request_handlers/anvil/getAnvilCpu.ts @@ -1,4 +1,3 @@ -import assert from 'assert'; import { RequestHandler } from 'express'; import { query } from '../../accessModule'; @@ -49,14 +48,14 @@ export const getAnvilCpu: RequestHandler = async ( c.scan_hardware_cpu_threads ORDER BY b.host_name;`, ); - - assert.ok(rCpus.length, 'No entry found'); } catch (error) { stderr(`Failed to get anvil ${anvilUuid} cpu info; CAUSE: ${error}`); return response.status(500).send(); } + if (!rCpus.length) return response.status(404).send(); + let rAllocatedRow: [cpuAllocated: string][]; try { @@ -74,14 +73,14 @@ export const getAnvilCpu: RequestHandler = async ( ON a.server_uuid = b.server_definition_server_uuid WHERE a.server_anvil_uuid = '${anvilUuid}';`, ); - - assert.ok(rAllocatedRow.length, 'No entry found'); } catch (error) { stderr(`Failed to get anvil ${anvilUuid} server cpu info; CAUSE: ${error}`); return response.status(500).send(); } + if (!rAllocatedRow.length) return response.status(404).send(); + const { 0: { 5: rMinCores, 6: rMinThreads }, } = rCpus;