mirror of https://github.com/zulip/zulip.git
errors: Stop showing a long list of Nones when there's no request.
This had contributed to making the emails look broken and of uncertain accuracy.
This commit is contained in:
parent
68fa29c3ec
commit
77e47900dd
|
@ -110,13 +110,16 @@ def zulip_server_error(report: Dict[str, Any]) -> None:
|
|||
user_info = user_info_str(report)
|
||||
deployment = deployment_repr()
|
||||
|
||||
request_repr = (
|
||||
"Request info:\n~~~~\n"
|
||||
"- path: %(path)s\n"
|
||||
"- %(method)s: %(data)s\n") % (report)
|
||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
||||
request_repr += "~~~~"
|
||||
if report['has_request']:
|
||||
request_repr = (
|
||||
"Request info:\n~~~~\n"
|
||||
"- path: %(path)s\n"
|
||||
"- %(method)s: %(data)s\n") % (report)
|
||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
||||
request_repr += "~~~~"
|
||||
else:
|
||||
request_repr = "Request info: none"
|
||||
|
||||
message = ("Error generated by %s\n\n~~~~ pytb\n%s\n\n~~~~\n%s\n%s"
|
||||
% (user_info, report['stack_trace'], deployment, request_repr))
|
||||
|
@ -131,12 +134,15 @@ def email_server_error(report: Dict[str, Any]) -> None:
|
|||
user_info = user_info_str(report)
|
||||
deployment = deployment_repr()
|
||||
|
||||
request_repr = (
|
||||
"Request info:\n"
|
||||
"- path: %(path)s\n"
|
||||
"- %(method)s: %(data)s\n") % (report)
|
||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
||||
if report['has_request']:
|
||||
request_repr = (
|
||||
"Request info:\n"
|
||||
"- path: %(path)s\n"
|
||||
"- %(method)s: %(data)s\n") % (report)
|
||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
||||
else:
|
||||
request_repr = "Request info: none\n"
|
||||
|
||||
message = ("Error generated by %s\n\n%s\n\n%s\n\n%s"
|
||||
% (user_info, report['stack_trace'], deployment, request_repr))
|
||||
|
|
|
@ -14,6 +14,8 @@ from django.views.debug import ExceptionReporter, get_exception_reporter_filter
|
|||
from zerver.lib.queue import queue_json_publish
|
||||
|
||||
def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:
|
||||
report['has_request'] = True
|
||||
|
||||
report['path'] = request.path
|
||||
report['method'] = request.method
|
||||
report['remote_addr'] = request.META.get('REMOTE_ADDR', None),
|
||||
|
|
Loading…
Reference in New Issue