From e1ed93cf8e334b3e848069a8beed5dffcc1bd777 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sun, 19 May 2024 10:03:16 -0500 Subject: [PATCH] API: return error when no ports found When looking up device ports (get_port_graphs), return an error when no ports are found. fixes #15964 --- includes/html/api_functions.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/html/api_functions.inc.php b/includes/html/api_functions.inc.php index 3ca998705829..081089d1df78 100644 --- a/includes/html/api_functions.inc.php +++ b/includes/html/api_functions.inc.php @@ -1070,6 +1070,10 @@ function get_port_graphs(Illuminate\Http\Request $request): JsonResponse $ports = $device->ports()->isNotDeleted()->hasAccess(Auth::user()) ->select($columns)->orderBy('ifIndex')->get(); + if ($ports->isEmpty()) { + return api_error(404, 'No ports found'); + } + return api_success($ports, 'ports'); }