[Django] #32637: Http404 exception messages might not be propagating to 404 debug templates in Django 3.2

41 views
Skip to first unread message

Django

unread,
Apr 12, 2021, 8:15:30 AM4/12/21
to django-...@googlegroups.com
#32637: Http404 exception messages might not be propagating to 404 debug templates
in Django 3.2
-----------------------------------------+------------------------
Reporter: Atul Varma | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.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 |
-----------------------------------------+------------------------
Hello! I'm currently upgrading a project from Django 2.2 to 3.2 (a bit
sloppily, as I'm not incrementally upgrading to intermediate versions). I
noticed that a few of my tests rely on the following behavior specified in
the documentation for the Http404 exception:

> When DEBUG is True, you can provide a message to Http404 and it will
appear in the standard 404 debug template. Use these messages for
debugging purposes; they generally aren’t suitable for use in a production
404 template.

I was able to test whether the message I passed was visible on the debug
404 page for the view (to make sure the page was 404'ing for the right
reason). However, these tests have broken when upgrading to Django 3.2.
Looking at the actual response content, it doesn't seem as though the
actual message is visible anywhere on the page.

I'm currently just going to comment out the explicit test for finding the
exception message, but I was curious if anyone else has found this kind of
error as well, or if it's just me. If needed, I can try creating a simple
test case that reproduces this error (though I'll admit the problem could
be entirely on my end too).

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

Django

unread,
Apr 12, 2021, 2:50:17 PM4/12/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
---------------------------------+------------------------------------

Reporter: Atul Varma | Owner: nobody
Type: Bug | Status: new
Component: Error reporting | Version: 3.2
Severity: Release blocker | 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):

* cc: Jon Dufresne (added)
* component: Uncategorized => Error reporting
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted


Comment:

Thanks for this report. Technical 404 debug page now always shows tried
URL patterns, that's why
[https://github.com/django/django/blob/e4430f22c8e3d29ce5d9d0263fba57121938d06d/django/views/templates/technical_404.html#L69-L71
Http404's message] is no longer displayed. IMO we should keep showing a
message, e.g.

{{{
diff --git a/django/views/templates/technical_404.html
b/django/views/templates/technical_404.html
index 077bb20964..aeba2daf9c 100644
--- a/django/views/templates/technical_404.html
+++ b/django/views/templates/technical_404.html
@@ -20,11 +20,13 @@
#info ol li { font-family: monospace; }
#summary { background: #ffc; }
#explanation { background:#eee; border-bottom: 0px none; }
+ pre.exception_value { font-family: sans-serif; color: #575757; font-
size: 1.5em; margin: 10px 0 10px 0; }
</style>
</head>
<body>
<div id="summary">
<h1>Page not found <span>(404)</span></h1>
+ {% if reason %}<pre class="exception_value">{{ reason }}</pre>{%
endif %}
<table class="meta">
<tr>
<th>Request Method:</th>
@@ -66,8 +68,6 @@
{% endif %}
{% if resolved %}matched the last one.{% else %}didn’t match any
of these.{% endif %}
</p>
- {% else %}
- <p>{{ reason }}</p>
{% endif %}
</div>
}}}

Regression in 11ebc6479ffda87376b60c9475d33d8120f86368.

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

Django

unread,
Apr 12, 2021, 3:21:01 PM4/12/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
---------------------------------+------------------------------------
Reporter: Atul Varma | Owner: nobody
Type: Bug | Status: new
Component: Error reporting | Version: 3.2
Severity: Release blocker | 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 Claude Paroz):

+1 for fixing that regression.

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

Django

unread,
Apr 13, 2021, 12:19:39 AM4/13/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
-------------------------------------+-------------------------------------
Reporter: Atul Varma | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned

Component: Error reporting | Version: 3.2
Severity: Release blocker | 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):

* owner: nobody => Mariusz Felisiak
* status: new => assigned


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

Django

unread,
Apr 13, 2021, 12:45:30 AM4/13/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
-------------------------------------+-------------------------------------
Reporter: Atul Varma | Owner: Mariusz
| Felisiak
Type: Bug | Status: assigned
Component: Error reporting | Version: 3.2
Severity: Release blocker | 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 Mariusz Felisiak):

* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Apr 13, 2021, 3:15:20 AM4/13/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
-------------------------------------+-------------------------------------
Reporter: Atul Varma | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed

Component: Error reporting | Version: 3.2
Severity: Release blocker | Resolution: fixed
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 GitHub <noreply@…>):

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


Comment:

In [changeset:"3b8527e32b665df91622649550813bb1ec9a9251" 3b8527e3]:
{{{
#!CommitTicketReference repository=""
revision="3b8527e32b665df91622649550813bb1ec9a9251"
Fixed #32637 -- Restored exception message on technical 404 debug page.

Thanks Atul Varma for the report.
}}}

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

Django

unread,
Apr 13, 2021, 3:15:51 AM4/13/21
to django-...@googlegroups.com
#32637: Technical 404 debug page doesn't display Http404's message in Django 3.2.
-------------------------------------+-------------------------------------
Reporter: Atul Varma | Owner: Mariusz
| Felisiak
Type: Bug | Status: closed
Component: Error reporting | Version: 3.2
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
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:"d6314c4c2ef647efe0d12450214fc5b4a4055290" d6314c4]:
{{{
#!CommitTicketReference repository=""
revision="d6314c4c2ef647efe0d12450214fc5b4a4055290"
[3.2.x] Fixed #32637 -- Restored exception message on technical 404 debug
page.

Thanks Atul Varma for the report.

Backport of 3b8527e32b665df91622649550813bb1ec9a9251 from main
}}}

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

Reply all
Reply to author
Forward
0 new messages