Issue #2050
closedHTTP 500 rather than a HTTP 404 when a missing resource is requested
Description
In current master, requesting a URL that doesn't exist triggers a 404, but that triggers a 500 when Django encounters the following error:
Jul 01 13:10:51 dev pulp[1928]: django.request:WARNING: Not Found: /var/www/pub/yum/https/repos/NaN
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) Internal Server Error: /var/www/pub/yum/https/repos/NaN
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) Traceback (most recent call last):
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 92, in get_exception_response
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) response = callback(request, **dict(param_dict, exception=exception))
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) response = view_func(request, *args, **kwargs)
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/views/defaults.py", line 40, in page_not_found
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) body = template.render(context, request)
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/template/backends/django.py", line 95, in render
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) return self.template.render(context)
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/template/base.py", line 204, in render
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) with context.bind_template(self):
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) return self.gen.next()
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/template/context.py", line 260, in bind_template
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) updates.update(processor(self.request))
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/contrib/auth/context_processors.py", line 60, in auth
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) from django.contrib.auth.models import AnonymousUser
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/contrib/auth/models.py", line 6, in <module>
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) from django.contrib.contenttypes.models import ContentType
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 161, in <module>
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) class ContentType(models.Model):
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) File "/usr/lib/python2.7/site-packages/django/db/models/base.py", line 102, in __new__
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) "INSTALLED_APPS." % (module, name)
Jul 01 13:10:51 dev pulp[1928]: django.request:ERROR: (1928-96352) RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
This is quite unpleasant and it's unclear what went wrong unless you look at the logs and realize it's a HTTP 404.
To reproduce:
1. Request a url that doesn't exist. Something like https://dev.example.com/pulp/repos/NaN
2. See a HTTP 500
Note this occurs with python2-django-1.9.7-1.fc24.noarch
Updated by amacdona@redhat.com almost 8 years ago
- Triaged changed from No to Yes
Updated by bmbouter almost 8 years ago
I tried to reproduce this with these version but couldn't.
[vagrant@dev ~]$ rpm -qa | grep django
python-django-1.8.11-1.fc23.noarch
python-django-bash-completion-1.8.11-1.fc23.noarch
So this must be a problem with newer versions?
[vagrant@dev ~]$ curl https://dev.example.com/pulp/repos/NaN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Not Found</title>
</head>
<body>
<h1>HTTP 404: Not found.</h1>
<p>The URL you requested was not found on this server.</p>
</body>
</html>
Updated by amacdona@redhat.com over 7 years ago
Could not reproduce with Django 1.9.8
(pulp) [vagrant@dev pulp]$ pip freeze | grep Django
Django==1.9.8
(pulp) [vagrant@dev pulp]$ curl https://dev.example.com/pulp/NaN/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /pulp/NaN/ was not found on this server.</p>
</body></html>
Updated by fdobrovo over 7 years ago
Django 1.9.8:
[vagrant@dev pulp]$ pip freeze | grep Django
Django==1.9.8
[vagrant@dev pulp]$ rpm -qa | grep django
python-django-bash-completion-1.9.8-1.fc24.noarch
python2-django-1.9.8-1.fc24.noarch
[vagrant@dev pulp]$ curl https://dev.example.com/pulp/NaN/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /pulp/NaN/ was not found on this server.</p>
</body></html>
Django 1.9.7
(pulp) [vagrant@dev pulp]$ pip freeze | grep Django
Django==1.9.7
(pulp) [vagrant@dev pulp]$ curl https://dev.example.com/pulp/NaN/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /pulp/NaN/ was not found on this server.</p>
</body></html>
And journal is clean.
I also was not able to reproduce it, but I belive that this error is connected to this:
http://stackoverflow.com/questions/29635765/django-1-9-deprecation-warnings-app-label
And is something simmilar to:
https://github.com/getsentry/raven-python/issues/705
Updated by ipanova@redhat.com over 7 years ago
based on provided info and feedback i guess we can close this issue, @jcline?
Updated by jcline@redhat.com over 7 years ago
- Status changed from NEW to CLOSED - WORKSFORME