From 8cb4799196fa8ef75fb125e575c50e0ba34d3e7b Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 26 Mar 2026 10:19:52 -0500 Subject: [PATCH] show validation errors in json response --- frigate/api/app.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/frigate/api/app.py b/frigate/api/app.py index 498094ff8..0126e5d03 100644 --- a/frigate/api/app.py +++ b/frigate/api/app.py @@ -613,6 +613,34 @@ def config_set(request: Request, body: AppConfigSetBody): try: config = FrigateConfig.parse(new_raw_config) + except ValidationError as e: + with open(config_file, "w") as f: + f.write(old_raw_config) + f.close() + logger.error( + f"Config Validation Error:\n\n{str(traceback.format_exc())}" + ) + error_messages = [] + for err in e.errors(): + msg = err.get("msg", "") + # Strip pydantic "Value error, " prefix for cleaner display + if msg.startswith("Value error, "): + msg = msg[len("Value error, ") :] + error_messages.append(msg) + message = ( + "; ".join(error_messages) + if error_messages + else "Check logs for error message." + ) + return JSONResponse( + content=( + { + "success": False, + "message": f"Error saving config: {message}", + } + ), + status_code=400, + ) except Exception: with open(config_file, "w") as f: f.write(old_raw_config)