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" + } + } + } } } },