From 68f214ff29ffabb90860e4a2f93b203cb39ea55e Mon Sep 17 00:00:00 2001 From: fipwmaqzufheoxq92ebc <29818044+fipwmaqzufheoxq92ebc@users.noreply.github.com> Date: Fri, 21 Aug 2020 12:50:36 +0200 Subject: [PATCH] Fixes #956. Return 404 for missing objects in GenericEntityApiController.php --- controllers/GenericEntityApiController.php | 4 ++++ grocy.openapi.json | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/controllers/GenericEntityApiController.php b/controllers/GenericEntityApiController.php index 3a2f1754..de0775ac 100644 --- a/controllers/GenericEntityApiController.php +++ b/controllers/GenericEntityApiController.php @@ -50,6 +50,10 @@ class GenericEntityApiController extends BaseApiController } $object = $this->getDatabase()->{$args['entity']}($args['objectId']); + if ($object == null) { + return $this->GenericErrorResponse($response, 'Object not found', 404); + } + $object['userfields'] = $userfields; return $this->ApiResponse($response, $object); diff --git a/grocy.openapi.json b/grocy.openapi.json index 20af6b9f..b8d587b1 100644 --- a/grocy.openapi.json +++ b/grocy.openapi.json @@ -395,6 +395,16 @@ } } } + }, + "404": { + "description": "Object not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenericErrorResponse" + } + } + } } } },