Project

Profile

Help

Issue #2050

closed

HTTP 500 rather than a HTTP 404 when a missing resource is requested

Added by jcline@redhat.com over 7 years ago. Updated almost 5 years ago.

Status:
CLOSED - WORKSFORME
Priority:
High
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
1. Low
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Pulp 2
Sprint:
Quarter:

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

Also available in: Atom PDF