Skip to content

Commit 6cbfc2a

Browse files
talih0stephenfin
authored andcommitted
views: Return Http404 if patch not found
Otherwise exception DoesNotExist shows error 500 on Apache Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #343
1 parent cdf43a7 commit 6cbfc2a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

patchwork/views/patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ def patch_detail(request, project_id, msgid):
4141
# redirect to cover letters where necessary
4242
try:
4343
patch = Patch.objects.get(project_id=project.id, msgid=db_msgid)
44-
except Patch.DoesNotExist as exc:
44+
except Patch.DoesNotExist:
4545
submissions = Submission.objects.filter(project_id=project.id,
4646
msgid=db_msgid)
4747
if submissions:
4848
return HttpResponseRedirect(
4949
reverse('cover-detail',
5050
kwargs={'project_id': project.linkname,
5151
'msgid': msgid}))
52-
raise exc
52+
raise Http404('Patch does not exist')
5353

5454
editable = patch.is_editable(request.user)
5555
context = {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Previously, attempting to retrieve a patch that did not exist would result
5+
in a ``HTTP 500`` (Internal Server Error) being raised. This has been
6+
corrected and a ``HTTP 404`` (Not Found) is now raised instead.

0 commit comments

Comments
 (0)