mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
logging_util: Handle record.status_code missing in skip_200_and_304.
Fixes #14595. Invalid HTTP requests could end up in an unhandled exception in skip_200_and_304 due the record not having the status_code attribute set. With this change we'll avoid the exception Example: curl -X POST -H 'Transfer-Encoding : chunked' --data-binary 'a' 'http://zulipdev.com:9991/json/messages/57' 2020-04-21 10:56:22.007 WARN [django.server] "POST /json/messages/57 HTTP/1.1" 405 95 2020-04-21 10:56:22.007 INFO [django.server] code 400, message Bad request syntax ('a') 2020-04-21 10:56:22.008 WARN [django.server] "a" 400 -
This commit is contained in:
committed by
Tim Abbott
parent
fead14951c
commit
ec6022a186
@@ -119,7 +119,7 @@ def skip_200_and_304(record: logging.LogRecord) -> bool:
|
|||||||
# Apparently, `status_code` is added by Django and is not an actual
|
# Apparently, `status_code` is added by Django and is not an actual
|
||||||
# attribute of LogRecord; as a result, mypy throws an error if we
|
# attribute of LogRecord; as a result, mypy throws an error if we
|
||||||
# access the `status_code` attribute directly.
|
# access the `status_code` attribute directly.
|
||||||
if getattr(record, 'status_code') in [200, 304]:
|
if getattr(record, 'status_code', None) in [200, 304]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user