From 54ec98cafb22daf6fbcc09c4f6fabff6fe5a4e30 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 21 May 2024 22:05:44 -0500 Subject: [PATCH] API: return error when no ports found (#16043) 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 3ca9987058..081089d1df 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'); }