mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-05 14:47:40 +03:00
show validation errors in json response
This commit is contained in:
parent
c6775549af
commit
8cb4799196
@ -613,6 +613,34 @@ def config_set(request: Request, body: AppConfigSetBody):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
config = FrigateConfig.parse(new_raw_config)
|
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:
|
except Exception:
|
||||||
with open(config_file, "w") as f:
|
with open(config_file, "w") as f:
|
||||||
f.write(old_raw_config)
|
f.write(old_raw_config)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user