Skip to content

Commit

Permalink
Fix opera log of non-dict request body (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan authored Jan 25, 2025
1 parent 20e873b commit 52816dd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion backend/middleware/opera_log_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ async def get_request_args(request: Request) -> dict:
json_data = await request.json()
if isinstance(json_data, bytes):
json_data = json_data.decode('utf-8')
args.update(json_data)
if isinstance(json_data, dict):
args.update(json_data)
else:
# 注意:非字典数据默认使用 body 作为键
args.update({'body': json_data})
else:
args.update({'body': str(body_data)})
return args
Expand Down

0 comments on commit 52816dd

Please sign in to comment.