[Django] #33396: Add the ResolverMatch's name to the technical 500 page.

21 views
Skip to first unread message

Django

unread,
Dec 29, 2021, 6:41:44 AM12/29/21
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------------+------------------------
Reporter: Keryn Knight | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: dev
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 |
-------------------------------------------+------------------------
Way back when in #22756, I asked for and was given a lovely addition to
the **technical 404 page**, so that when `raise Http404('...')` was used
it would report the view being executed, so that coming back to a project
and getting an error would give me a hint where to look.

It looks like this, give or take alignment:
{{{
Request Method: GET
Request URL: http://localhost:8080/egsdh
Raised by: __main__.ItemDetail
}}}

Today I'm here to ask for the same in the **technical 500 page**.
I just opened a project from ''about 3 weeks ago'' and in that short time
had apparently forgotten what views were mounted on what URLs, and however
many years after that ticket, Django still doesn't have a management
command for printing me the URLs (... sigh), so I had to go digging again
to deal with the error I'd evidently left myself.

`django.views.debug.ExceptionReporter.get_traceback_data` already has
awareness of the request (`if self.request is not None`) which it uses to
print the GET/POST/etc. I'd like to suggest that within that block, we do
something like:

{{{
if self.request is not None:
try:
view_name = self.request.resolver_match._func_path
except Exception:
view_name = None
c['view_name'] = view_name
}}}

and then adjust the template to have a `Raised by: {{ view_name }}` line
as the technical 404 page, guarding it with an `{% if %}` test. We might
want to change the label from `Raised by` across both to something like
`Raised during` or `During View` or something ...

The 500 page might thus look something like:
{{{
Request Method: GET
Request URL: http://localhost:8080/
View name: __main__.ItemList
Django Version: 4.x.x
Exception Type: ZeroDivisionError
Exception Value:division by zero
...
}}}

By the look of it, the code for the technical 404 page and the
ResolverMatch name may ''mostly'' overlap in terms of calculation/output,
except:
- #32260 was relatively recently patched into the 404 page, so that
references `.view_class`
- `ResolverMatch` is separately ''aware'' that the `func` might be a
`functools.partial`, but only within the `__repr__`
So it's possible there could be some tidying up/DRY aside from those
edges.

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

Django

unread,
Dec 29, 2021, 7:02:15 AM12/29/21
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
---------------------------------+------------------------------------

Reporter: Keryn Knight | Owner: (none)
Type: New feature | Status: new
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

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

* stage: Unreviewed => Accepted


Comment:

Sounds reasonable.

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

Django

unread,
Dec 29, 2021, 7:16:26 AM12/29/21
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
---------------------------------+----------------------------------------
Reporter: Keryn Knight | Owner: Keryn Knight
Type: New feature | Status: assigned

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

* owner: (none) => Keryn Knight
* status: new => assigned


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

Django

unread,
Jan 1, 2022, 1:43:50 AM1/1/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
---------------------------------+----------------------------------------
Reporter: Keryn Knight | Owner: Keryn Knight
Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------
Changes (by Hrushikesh Vaidya):

* cc: Hrushikesh Vaidya (added)


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

Django

unread,
Jan 6, 2022, 9:37:12 AM1/6/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
---------------------------------+----------------------------------------
Reporter: Keryn Knight | Owner: Keryn Knight
Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------------------------

Comment (by Hrushikesh Vaidya):

I have a quick [https://github.com/django/django/pull/15286 PR] for an
initial patch that addresses the feature, except the DRYing up of the
technical 404 and ResolverMatch.

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

Django

unread,
Jan 7, 2022, 3:00:44 AM1/7/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
| Hrushikesh Vaidya

Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: Keryn Knight => Hrushikesh Vaidya
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

I hope you don't mind Keryn.

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

Django

unread,
Jan 8, 2022, 10:23:04 PM1/8/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
| Hrushikesh Vaidya
Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* needs_better_patch: 1 => 0
* needs_tests: 1 => 0


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

Django

unread,
Jan 10, 2022, 1:41:30 AM1/10/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
| Hrushikesh Vaidya
Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 13, 2022, 4:08:18 AM1/13/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
| Hrushikesh Vaidya
Type: New feature | Status: assigned
Component: Error reporting | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

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

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"4099e6e73744ef6a609b578020219f6e4647dd7e" 4099e6e7]:
{{{
#!CommitTicketReference repository=""
revision="4099e6e73744ef6a609b578020219f6e4647dd7e"
Refs #33396 -- Added django.views.debug.get_caller() hook.
}}}

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

Django

unread,
Jan 13, 2022, 4:08:18 AM1/13/22
to django-...@googlegroups.com
#33396: Add the ResolverMatch's name to the technical 500 page.
-------------------------------------+-------------------------------------
Reporter: Keryn Knight | Owner:
| Hrushikesh Vaidya
Type: New feature | Status: closed

Component: Error reporting | Version: dev
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: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"6815da6e9497a9a630d9f3637a51134d868bcd5b" 6815da6e]:
{{{
#!CommitTicketReference repository=""
revision="6815da6e9497a9a630d9f3637a51134d868bcd5b"
Fixed #33396 -- Added view name to technical 500 debug page.
}}}

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

Reply all
Reply to author
Forward
0 new messages