From cf16eda76ed7e0521a70931e8b5b202707b80379 Mon Sep 17 00:00:00 2001 From: Logan Garrett Date: Mon, 17 Mar 2025 23:01:40 -0400 Subject: [PATCH] Fix key error when model path key doesn't exist. (#17217) * fixed metrics race condition * ruff formatting * adjust for default path config * ruff * check for model too --- frigate/api/app.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frigate/api/app.py b/frigate/api/app.py index 9d7b3768f..f19070a3a 100644 --- a/frigate/api/app.py +++ b/frigate/api/app.py @@ -177,14 +177,18 @@ def config(request: Request): # Add model plus data if plus is enabled if config["plus"]["enabled"]: - model_json_path = FilePath(config["model"]["path"]).with_suffix(".json") - try: - with open(model_json_path, "r") as f: - model_plus_data = json.load(f) - config["model"]["plus"] = model_plus_data - except FileNotFoundError: - config["model"]["plus"] = None - except json.JSONDecodeError: + model_path = config.get("model", {}).get("path") + if model_path: + model_json_path = FilePath(model_path).with_suffix(".json") + try: + with open(model_json_path, "r") as f: + model_plus_data = json.load(f) + config["model"]["plus"] = model_plus_data + except FileNotFoundError: + config["model"]["plus"] = None + except json.JSONDecodeError: + config["model"]["plus"] = None + else: config["model"]["plus"] = None # use merged labelamp