From 605d051b3db358a5a97c7c02d7c184e1b94a62c1 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 17 Sep 2026 16:55:06 -0500 Subject: [PATCH] check for a valid frame before using its shape With the camera offline, no preview frame, and `camera-error.jpg` missing, `latest_frame` read `frame.shape` before its `frame is None` check, so it raised `AttributeError` and answered 500 with a traceback instead of the intended "Unable to get valid frame". The check now runs first. --- frigate/api/media.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frigate/api/media.py b/frigate/api/media.py index e7e4edfdce..6a15952b5e 100644 --- a/frigate/api/media.py +++ b/frigate/api/media.py @@ -258,15 +258,15 @@ async def latest_frame( frame = request.app.camera_error_image - height = int(params.height or str(frame.shape[0])) - width = int(height * frame.shape[1] / frame.shape[0]) - if frame is None: return JSONResponse( content={"success": False, "message": "Unable to get valid frame"}, status_code=500, ) + height = int(params.height or str(frame.shape[0])) + width = int(height * frame.shape[1] / frame.shape[0]) + if height < 1 or width < 1: return JSONResponse( content="Invalid height / width requested :: {} / {}".format(