Skip to content

Commit 52816dd

Browse files
authored
Fix opera log of non-dict request body (#501)
1 parent 20e873b commit 52816dd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

backend/middleware/opera_log_middleware.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ async def get_request_args(request: Request) -> dict:
138138
json_data = await request.json()
139139
if isinstance(json_data, bytes):
140140
json_data = json_data.decode('utf-8')
141-
args.update(json_data)
141+
if isinstance(json_data, dict):
142+
args.update(json_data)
143+
else:
144+
# 注意:非字典数据默认使用 body 作为键
145+
args.update({'body': json_data})
142146
else:
143147
args.update({'body': str(body_data)})
144148
return args

0 commit comments

Comments
 (0)