fix: handle missing user agent in request logs

This commit is contained in:
caoqianming 2026-03-19 21:52:23 +08:00
parent 4a053143f4
commit fbe12249f8
1 changed files with 4 additions and 1 deletions

View File

@ -466,7 +466,10 @@ class MyLoggingMixin(object):
def _get_agent(self, request):
"""Get os string"""
return str(parse(request.META['HTTP_USER_AGENT']))
user_agent = request.META.get('HTTP_USER_AGENT', '')
if not user_agent:
return ''
return str(parse(user_agent))
def _get_response_ms(self):
"""