OpenStack Dashboard (Horizon)

Server error pages are broken

Reported by Kieran Spear on 2012-10-16
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Medium
Kieran Spear
Folsom
Medium
Matthias Runge

Bug Description

When an unhandled exception occurs with DEBUG=False, openstack_dashboard tries to render the 500.html template but fails because it inherits the base.html template, which then includes _conf.html, which expects the STATIC_URL context variable to be present. 500 errors are a special case in Django because they are passed an empty Context rather than the usual RequestContext[1].

This results in a somewhat cryptic compressor error:

[Tue Oct 16 00:30:39 2012] [error] [client 128.250.116.167] UncompressableFileError: 'horizon/js/horizon.js' isn't accessible via COMPRESS_URL ('/static/') and can't be compressed

...which you can eventually trace back to this line in horizon/_conf.html:

<script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript' charset='utf-8'></script>

...where STATIC_URL evaluates to an empty string.

From a discussion[2] on the Django dev list it looks like there are a few options:

1) Make the error page simpler (i.e., don't inherit base.html)
2) Replace use of STATIC_URL with the staticfiles 'static' templatetag[3]. There may be other context variables in templates that are still missing though.
3) Override the handler and pass in the RequestContext anyway (this is exactly what Django is attempting to avoid, since any errors in generating the context will break your error page).

I think (1) is reasonable and low maintenance. What do you think?

[1] https://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view
[2] https://groups.google.com/forum/#!topic/django-developers/UH8ehYL8Pss/discussion
[3] https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#static

Changed in horizon:
importance: Undecided → Medium
milestone: none → grizzly-1
status: New → Confirmed

Fix proposed to branch: master
Review: https://review.openstack.org/16152

Changed in horizon:
assignee: nobody → Kieran Spear (kspear)
status: Confirmed → In Progress

Reviewed: https://review.openstack.org/16152
Committed: http://github.com/openstack/horizon/commit/76ef256dc47b590f205aa95c2d439282fb62c962
Submitter: Jenkins
Branch: master

commit 76ef256dc47b590f205aa95c2d439282fb62c962
Author: Kieran Spear <email address hidden>
Date: Wed Nov 14 18:30:39 2012 +1100

    Don't inherit from base.html in 500 error page

    For server errors, the context passed to the template is empty,
    so things like STATIC_URL and context processors don't work.

    Fixes bug 1067206.

    Change-Id: Ia1801afaecd6a23fbcc6054552d0fd313597d1c1

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-11-22
Changed in horizon:
status: Fix Committed → Fix Released

Reviewed: https://review.openstack.org/18298
Committed: http://github.com/openstack/horizon/commit/0b1c5536dfd80f071d8e3e92b71dc7eca0b1d325
Submitter: Jenkins
Branch: stable/folsom

commit 0b1c5536dfd80f071d8e3e92b71dc7eca0b1d325
Author: Matthias Runge <email address hidden>
Date: Wed Nov 14 18:30:39 2012 +1100

    Don't inherit from base.html in 500 error page

    For server errors, the context passed to the template is empty,
    so things like STATIC_URL and context processors don't work.

    Fixes bug 1067206 for the folsom branch.

    This has been adapted to folsom release and is a backport from master.

    Change-Id: I5cd60523360d71b088226e4d0f87d88bac8a8df3

Thierry Carrez (ttx) on 2013-04-04
Changed in horizon:
milestone: grizzly-1 → 2013.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers