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)
|
user_info = user_info_str(report)
|
||||||
deployment = deployment_repr()
|
deployment = deployment_repr()
|
||||||
|
|
||||||
request_repr = (
|
if report['has_request']:
|
||||||
"Request info:\n~~~~\n"
|
request_repr = (
|
||||||
"- path: %(path)s\n"
|
"Request info:\n~~~~\n"
|
||||||
"- %(method)s: %(data)s\n") % (report)
|
"- path: %(path)s\n"
|
||||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
"- %(method)s: %(data)s\n") % (report)
|
||||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
||||||
request_repr += "~~~~"
|
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"
|
message = ("Error generated by %s\n\n~~~~ pytb\n%s\n\n~~~~\n%s\n%s"
|
||||||
% (user_info, report['stack_trace'], deployment, request_repr))
|
% (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)
|
user_info = user_info_str(report)
|
||||||
deployment = deployment_repr()
|
deployment = deployment_repr()
|
||||||
|
|
||||||
request_repr = (
|
if report['has_request']:
|
||||||
"Request info:\n"
|
request_repr = (
|
||||||
"- path: %(path)s\n"
|
"Request info:\n"
|
||||||
"- %(method)s: %(data)s\n") % (report)
|
"- path: %(path)s\n"
|
||||||
for field in ["REMOTE_ADDR", "QUERY_STRING", "SERVER_NAME"]:
|
"- %(method)s: %(data)s\n") % (report)
|
||||||
request_repr += "- %s: \"%s\"\n" % (field, report.get(field.lower()))
|
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"
|
message = ("Error generated by %s\n\n%s\n\n%s\n\n%s"
|
||||||
% (user_info, report['stack_trace'], deployment, request_repr))
|
% (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
|
from zerver.lib.queue import queue_json_publish
|
||||||
|
|
||||||
def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:
|
def add_request_metadata(report: Dict[str, Any], request: HttpRequest) -> None:
|
||||||
|
report['has_request'] = True
|
||||||
|
|
||||||
report['path'] = request.path
|
report['path'] = request.path
|
||||||
report['method'] = request.method
|
report['method'] = request.method
|
||||||
report['remote_addr'] = request.META.get('REMOTE_ADDR', None),
|
report['remote_addr'] = request.META.get('REMOTE_ADDR', None),
|
||||||
|
|
Loading…
Reference in New Issue