Skip to content

Commit aa978ec

Browse files
committed
fix: notify check invalid json
1 parent 5e60987 commit aa978ec

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/notify_admin/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fastapi import Request, APIRouter
1+
from fastapi import Request, APIRouter, HTTPException
22
from aiohttp import ClientSession
33
from loguru import logger
44

@@ -8,7 +8,12 @@
88

99
@router.post("/notify_admin")
1010
async def notify_admin(request: Request):
11-
body = await request.json()
11+
try:
12+
body = await request.json()
13+
except Exception as e:
14+
logger.error(f"notify_admin invalid json: {e}")
15+
raise HTTPException(status_code=400, detail="Invalid JSON")
16+
1217
logger.info(str(body))
1318

1419
if not settings.notify_admin_url:

0 commit comments

Comments
 (0)