From a7719846196d6481374349a84814bd90d95a055d Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 18 May 2022 06:15:46 -0500 Subject: [PATCH] Add an early return if for some reason the import record is not found --- app/Http/Controllers/Api/ImportController.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ImportController.php b/app/Http/Controllers/Api/ImportController.php index 0e8d969815..e5f0c6ab1f 100644 --- a/app/Http/Controllers/Api/ImportController.php +++ b/app/Http/Controllers/Api/ImportController.php @@ -134,7 +134,14 @@ class ImportController extends Controller \Log::debug('NO BACKUP requested via importer'); } - $errors = $request->import(Import::find($import_id)); + $import = Import::find($import_id); + + if(is_null($import)){ + $error[0][0] = trans("validation.exists", ["attribute" => "file"]); + return response()->json(Helper::formatStandardApiResponse('import-errors', null, $error), 500); + } + + $errors = $request->import($import); $redirectTo = 'hardware.index'; switch ($request->get('import-type')) { case 'asset':