[Django] #36243: Potential issue with the defaults.server_error method

7 views
Skip to first unread message

Django

unread,
Mar 10, 2025, 11:26:36 AM3/10/25
to django-...@googlegroups.com
#36243: Potential issue with the defaults.server_error method
--------------------------------+-----------------------------------------
Reporter: Bryant Glisson | Type: Bug
Status: new | Component: Uncategorized
Version: 4.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
--------------------------------+-----------------------------------------
We have the following custom error method:


{{{
@requires_csrf_token
def server_500(request, template_name='views/500.html'):
return http.HttpResponseServerError(render(request, template_name))
}}}

This works fine, but for standardization purposes, I was going to change
the code to the following:


{{{
@requires_csrf_token
def server_500(request, template_name='views/500.html'):
return defaults.server_error(request, template_name)
}}}


This results in an infinite error loop. The issue is that our 500 template
draws on context that is included in context processors. When it is
accessed via the first method, the additional context we've provided via
these processors is included. When accessed via the default method, this
context is not included, resulting in errors, which in turn trigger
another 500 error.

I didn't know if this was expected behavior for this method or not, but I
wanted to bring it to your attention.
--
Ticket URL: <https://code.djangoproject.com/ticket/36243>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 10, 2025, 12:49:30 PM3/10/25
to django-...@googlegroups.com
#36243: Potential issue with the defaults.server_error method
---------------------------------+--------------------------------------
Reporter: Bryant Glisson | Owner: (none)
Type: Bug | Status: closed
Component: Error reporting | Version: 4.2
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Sarah Boyce):

* component: Uncategorized => Error reporting
* resolution: => needsinfo
* status: new => closed

Comment:

Hi Bryant, can you share a minimal reproducible example?
--
Ticket URL: <https://code.djangoproject.com/ticket/36243#comment:1>
Reply all
Reply to author
Forward
0 new messages