fix: FormData not JSON serializable in validation handler, dashboard log to INFO
This commit is contained in:
@@ -53,7 +53,7 @@ async def dashboard(request: Request):
|
|||||||
)
|
)
|
||||||
total_revenue = float((await session.execute(rev_stmt)).scalar_one())
|
total_revenue = float((await session.execute(rev_stmt)).scalar_one())
|
||||||
|
|
||||||
logger.debug(
|
logger.info(
|
||||||
"Dashboard data: users={}/{} tariffs={} servers={}/{} payments={}/{} revenue={}",
|
"Dashboard data: users={}/{} tariffs={} servers={}/{} payments={}/{} revenue={}",
|
||||||
active_users, total_users, total_tariffs,
|
active_users, total_users, total_tariffs,
|
||||||
active_servers, total_servers,
|
active_servers, total_servers,
|
||||||
|
|||||||
@@ -62,11 +62,14 @@ async def validation_exception_handler(
|
|||||||
request: Request, exc: RequestValidationError
|
request: Request, exc: RequestValidationError
|
||||||
):
|
):
|
||||||
logger.warning("Validation error: {}", exc.errors())
|
logger.warning("Validation error: {}", exc.errors())
|
||||||
|
body = exc.body
|
||||||
|
if body is not None and not isinstance(body, (dict, list, str, int, float, bool, type(None))):
|
||||||
|
body = str(body)
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
status_code=422,
|
status_code=422,
|
||||||
content={
|
content={
|
||||||
"detail": exc.errors(),
|
"detail": exc.errors(),
|
||||||
"body": exc.body,
|
"body": body,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user