#36243 closed Bug (needsinfo)

Potential issue with the defaults.server_error method

Reported by: Bryant Glisson Owned by:
Component: Error reporting Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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.

Change History (1)

comment:1 by Sarah Boyce, 104 minutes ago

Component: UncategorizedError reporting
Resolution: needsinfo
Status: newclosed

Hi Bryant, can you share a minimal reproducible example?

Note: See TracTickets for help on using tickets.
Back to Top