[Django] #30411: Improve traceback formatting in technical 500 text responses

28 views
Skip to first unread message

Django

unread,
Apr 26, 2019, 1:42:58 PM4/26/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
------------------------------------------------+------------------------
Reporter: Daniel Hahler | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Other) | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I think it would do better without extra newlines, and could just match
the default output from Python itself.

Currently:

{{{
Traceback:

File "…/Vcs/django/django/template/base.py" in __init__
663. token.Meh

During handling of the above exception ('str' object has no attribute
'Meh'), another exception occurred:

File "…/Vcs/django/django/core/handlers/exception.py" in inner
34. response = get_response(request)

File "…/Vcs/django/django/core/handlers/base.py" in _get_response
145. response = self.process_exception_by_middleware(e,
request)

File "…/Vcs/django/django/core/handlers/base.py" in _get_response
143. response = response.render()

File "…/Vcs/django/django/template/response.py" in render
106. self.content = self.rendered_content

File "…/Vcs/django/django/template/response.py" in rendered_content
83. content = template.render(context, self._request)

File "…/Vcs/django/django/template/backends/django.py" in render
61. return self.template.render(context)

File "…/Vcs/django/django/template/base.py" in render
171. return self._render(context)

File "…/Vcs/django/django/test/utils.py" in instrumented_test_render
96. return self.nodelist.render(context)

File "…/Vcs/django/django/template/base.py" in render
940. bit = node.render_annotated(context)

File "…/Vcs/django/django/template/base.py" in render_annotated
907. return self.render(context)

File "…/Vcs/django/django/template/loader_tags.py" in render
150. return compiled_parent._render(context)

File "…/Vcs/django/django/test/utils.py" in instrumented_test_render
96. return self.nodelist.render(context)

File "…/Vcs/django/django/template/base.py" in render
940. bit = node.render_annotated(context)

File "…/Vcs/django/django/template/base.py" in render_annotated
907. return self.render(context)

File "…/Vcs/django/django/template/loader_tags.py" in render
127. compiled_parent = self.get_parent(context)

File "…/Vcs/django/django/template/loader_tags.py" in get_parent
124. return self.find_template(parent, context)

File "…/Vcs/django/django/template/loader_tags.py" in find_template
104. template_name, skip=history,

File "…/Vcs/django/django/template/engine.py" in find_template
125. template = loader.get_template(name, skip=skip)

File "…/Vcs/django/django/template/loaders/base.py" in get_template
30. contents, origin, origin.template_name,
self.engine,

File "…/Vcs/django/django/template/base.py" in __init__
156. self.nodelist = self.compile_nodelist()

File "…/Vcs/django/django/template/base.py" in compile_nodelist
194. return parser.parse()

File "…/Vcs/django/django/template/base.py" in parse
449. raise self.error(token, e)

File "…/Vcs/django/django/template/base.py" in parse
447. filter_expression =
self.compile_filter(token.contents)

File "…/Vcs/django/django/template/base.py" in compile_filter
563. return FilterExpression(token, self)

File "…/Vcs/django/django/template/base.py" in __init__
666. "from '%s'" %
(token[upto:], token))

Exception Type: TemplateSyntaxError at /a/login
Exception Value: Could not parse the remainder: '("foo")' from
'myecho("foo")'
}}}

Better:
{{{
Traceback (most recent call last):
File "…/Vcs/django/django/template/base.py", line 663, in __init__
token.Meh

During handling of the above exception ('str' object has no attribute
'Meh'), another exception occurred:
File "…/Vcs/django/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "…/Vcs/django/django/core/handlers/base.py", line 145, in
_get_response
response = self.process_exception_by_middleware(e, request)
File "…/Vcs/django/django/core/handlers/base.py", line 143, in
_get_response
response = response.render()
File "…/Vcs/django/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "…/Vcs/django/django/template/response.py", line 83, in
rendered_content
content = template.render(context, self._request)
File "…/Vcs/django/django/template/backends/django.py", line 61, in
render
return self.template.render(context)
File "…/Vcs/django/django/template/base.py", line 171, in render
return self._render(context)
File "…/Vcs/django/django/test/utils.py", line 96, in
instrumented_test_render
return self.nodelist.render(context)
File "…/Vcs/django/django/template/base.py", line 940, in render
bit = node.render_annotated(context)
File "…/Vcs/django/django/template/base.py", line 907, in
render_annotated
return self.render(context)
File "…/Vcs/django/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "…/Vcs/django/django/test/utils.py", line 96, in
instrumented_test_render
return self.nodelist.render(context)
File "…/Vcs/django/django/template/base.py", line 940, in render
bit = node.render_annotated(context)
File "…/Vcs/django/django/template/base.py", line 907, in
render_annotated
return self.render(context)
File "…/Vcs/django/django/template/loader_tags.py", line 127, in render
compiled_parent = self.get_parent(context)
File "…/Vcs/django/django/template/loader_tags.py", line 124, in
get_parent
return self.find_template(parent, context)
File "…/Vcs/django/django/template/loader_tags.py", line 104, in
find_template
template_name, skip=history,
File "…/Vcs/django/django/template/engine.py", line 125, in
find_template
template = loader.get_template(name, skip=skip)
File "…/Vcs/django/django/template/loaders/base.py", line 30, in
get_template
contents, origin, origin.template_name, self.engine,
File "…/Vcs/django/django/template/base.py", line 156, in __init__
self.nodelist = self.compile_nodelist()
File "…/Vcs/django/django/template/base.py", line 194, in
compile_nodelist
return parser.parse()
File "…/Vcs/django/django/template/base.py", line 449, in parse
raise self.error(token, e)
File "…/Vcs/django/django/template/base.py", line 447, in parse
filter_expression = self.compile_filter(token.contents)
File "…/Vcs/django/django/template/base.py", line 563, in compile_filter
return FilterExpression(token, self)
File "…/Vcs/django/django/template/base.py", line 666, in __init__
"from '%s'" % (token[upto:], token))

Exception Type: TemplateSyntaxError at /a/login
Exception Value: Could not parse the remainder: '("foo")' from
'myecho("foo")'

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30411>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 26, 2019, 10:26:49 PM4/26/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------

Reporter: Daniel Hahler | Owner: nobody
Type: | Status: new
Cleanup/optimization |

Component: Core (Other) | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Daniel Hahler):

There are two other issues here:

1. I would like to have it more at the bottom
2. the "Template error" part is not plain text:
{{{
Template error:
In template …/templates/base.html, error at line 10


Could not parse the remainder: '("foo")' from 'myecho("foo")'

1 : {# {% extends &quot;base.html&quot; %} #}
2 :

12 : &lt;/html&gt;
13 :
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:1>

Django

unread,
Apr 30, 2019, 3:02:46 PM4/30/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
--------------------------------------+------------------------------------

Reporter: Daniel Hahler | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Error reporting | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* component: Core (Other) => Error reporting
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

OK, fine, improvements here welcome. Marking Easy Pickings... since it
should just be formatting/template changes.

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:2>

Django

unread,
May 4, 2019, 6:51:19 PM5/4/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Naved
Type: | Khan
Cleanup/optimization | Status: assigned

Component: Error reporting | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Naved Khan):

* owner: nobody => Naved Khan
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:3>

Django

unread,
May 4, 2019, 10:51:50 PM5/4/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Naved
Type: | Khan
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Daniel Hahler):

@Naved
Just to make sure it's not missed, there is an initial PR already at
https://github.com/django/django/pull/11287.

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:4>

Django

unread,
May 6, 2019, 1:05:14 AM5/6/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Daniel
Type: | Hahler
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* owner: Naved Khan => Daniel Hahler
* has_patch: 0 => 1
* version: 2.2 => master


Comment:

[https://github.com/django/django/pull/11287 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:5>

Django

unread,
May 20, 2019, 4:41:33 AM5/20/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Daniel
Type: | Hahler
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:6>

Django

unread,
Jul 11, 2019, 5:33:13 AM7/11/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
--------------------------------------+------------------------------------
Reporter: Daniel Hahler | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Carlton Gibson):

* status: assigned => new
* owner: Daniel Hahler => (none)


Comment:

Deassigning due to inactivity.

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:7>

Django

unread,
Jul 21, 2019, 11:11:02 AM7/21/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
--------------------------------------+------------------------------------
Reporter: Daniel Hahler | Owner: (none)
Type: Cleanup/optimization | Status: new

Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by SunYiZheXinKe):

I'm new to Django and I am intending to accept this issue. However I have
a few questions to ask.
Firstly, how to make Django use technical_500.txt as a template? When I
raise exceptions in views Django use technical_500.html instead.
Secondly, why is the existing pull request not accepted, and how can I
improve it?

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:8>

Django

unread,
Jul 25, 2019, 9:50:10 PM7/25/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned

Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jerrod Martin):

* status: new => assigned

* owner: (none) => Jerrod Martin


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:9>

Django

unread,
Jul 25, 2019, 9:59:30 PM7/25/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jerrod Martin):

New pull request with tests. [https://github.com/django/django/pull/11596]

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:10>

Django

unread,
Jul 26, 2019, 1:34:35 AM7/26/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:11>

Django

unread,
Jul 26, 2019, 3:07:20 AM7/26/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:12>

Django

unread,
Jul 29, 2019, 5:11:01 AM7/29/19
to django-...@googlegroups.com
#30411: Improve traceback formatting in technical 500 text responses
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:13>

Django

unread,
Jul 29, 2019, 5:40:04 AM7/29/19
to django-...@googlegroups.com
#30411: Improve formatting of text tracebacks in technical 500 responses.

-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:14>

Django

unread,
Jul 29, 2019, 5:42:48 AM7/29/19
to django-...@googlegroups.com
#30411: Improve formatting of text tracebacks in technical 500 responses.
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: Jerrod
Type: | Martin
Cleanup/optimization | Status: closed

Component: Error reporting | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"c7bef16a749ccbe2dbc8ce6b697dc80146584384" c7bef16]:
{{{
#!CommitTicketReference repository=""
revision="c7bef16a749ccbe2dbc8ce6b697dc80146584384"
Fixed #30411 -- Improved formatting of text tracebacks in technical 500
templates.

Co-Authored-By: Daniel Hahler <g...@thequod.de>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30411#comment:15>

Reply all
Reply to author
Forward
0 new messages