]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
views: Return Http404 if patch not found
authorAndriy Gelman <andriy.gelman@gmail.com>
Wed, 11 Mar 2020 03:20:04 +0000 (23:20 -0400)
committerStephen Finucane <stephenfinucane@hotmail.com>
Wed, 11 Mar 2020 12:48:55 +0000 (12:48 +0000)
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
patchwork/views/patch.py
releasenotes/notes/issue-343-cb591d031cd58b61.yaml [new file with mode: 0644]

index f34053ce57da00dbac206e53ab420a567780bbf6..b368cfa4beb815019807ef1d1dbb70bddf6cf09f 100644 (file)
@@ -41,7 +41,7 @@ def patch_detail(request, project_id, msgid):
     # redirect to cover letters where necessary
     try:
         patch = Patch.objects.get(project_id=project.id, msgid=db_msgid)
-    except Patch.DoesNotExist as exc:
+    except Patch.DoesNotExist:
         submissions = Submission.objects.filter(project_id=project.id,
                                                 msgid=db_msgid)
         if submissions:
@@ -49,7 +49,7 @@ def patch_detail(request, project_id, msgid):
                 reverse('cover-detail',
                         kwargs={'project_id': project.linkname,
                                 'msgid': msgid}))
-        raise exc
+        raise Http404('Patch does not exist')
 
     editable = patch.is_editable(request.user)
     context = {
diff --git a/releasenotes/notes/issue-343-cb591d031cd58b61.yaml b/releasenotes/notes/issue-343-cb591d031cd58b61.yaml
new file mode 100644 (file)
index 0000000..8743676
--- /dev/null
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Previously, attempting to retrieve a patch that did not exist would result
+    in a ``HTTP 500`` (Internal Server Error) being raised. This has been
+    corrected and a ``HTTP 404`` (Not Found) is now raised instead.