From 3cd7e967c157d5daf36b9dc5f37ad212b620879c Mon Sep 17 00:00:00 2001 From: Ihor Marhitych Date: Wed, 2 Feb 2022 10:23:26 +0100 Subject: [PATCH] fix issue where bulk actions would return, not raise 404 return Http404 -> raise Http404 See #7911 --- CHANGELOG.txt | 6 ++++++ docs/releases/2.15.4.rst | 16 ++++++++++++++++ docs/releases/index.rst | 1 + .../pages/test_bulk_actions/test_bulk_action.py | 16 ++++++++++++++++ wagtail/admin/views/bulk_action/dispatcher.py | 4 ++-- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 docs/releases/2.15.4.rst create mode 100644 wagtail/admin/tests/pages/test_bulk_actions/test_bulk_action.py diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 60f647b8aa..d1f87352e1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,12 @@ Changelog ========= +2.15.4 (xx.xx.xxxx) - IN DEVELOPMENT +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych) + + 2.15.3 (26.01.2022) ~~~~~~~~~~~~~~~~~~~ diff --git a/docs/releases/2.15.4.rst b/docs/releases/2.15.4.rst new file mode 100644 index 0000000000..1766f0426e --- /dev/null +++ b/docs/releases/2.15.4.rst @@ -0,0 +1,16 @@ +============================================= +Wagtail 2.15.4 release notes - IN DEVELOPMENT +============================================= + +.. contents:: + :local: + :depth: 1 + + +What's new +========== + +Bug fixes +~~~~~~~~~ + + * Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych) diff --git a/docs/releases/index.rst b/docs/releases/index.rst index 6c5b5f289e..7de5a36cf6 100644 --- a/docs/releases/index.rst +++ b/docs/releases/index.rst @@ -5,6 +5,7 @@ Release notes :maxdepth: 1 upgrading + 2.15.4 2.15.3 2.15.2 2.15.1 diff --git a/wagtail/admin/tests/pages/test_bulk_actions/test_bulk_action.py b/wagtail/admin/tests/pages/test_bulk_actions/test_bulk_action.py new file mode 100644 index 0000000000..b2e33c1ca3 --- /dev/null +++ b/wagtail/admin/tests/pages/test_bulk_actions/test_bulk_action.py @@ -0,0 +1,16 @@ +from django.test import TestCase +from django.urls import reverse + +from wagtail.tests.utils import WagtailTestUtils + + +class TestBulkActionDispatcher(TestCase, WagtailTestUtils): + def setUp(self): + + # Login + self.user = self.login() + + def test_bulk_action_invalid_action(self): + url = reverse('wagtail_bulk_action', args=('wagtailcore', 'page', 'ships', )) + response = self.client.get(url) + self.assertEqual(response.status_code, 404) diff --git a/wagtail/admin/views/bulk_action/dispatcher.py b/wagtail/admin/views/bulk_action/dispatcher.py index de5fb64e32..718bc0af9d 100644 --- a/wagtail/admin/views/bulk_action/dispatcher.py +++ b/wagtail/admin/views/bulk_action/dispatcher.py @@ -1,5 +1,5 @@ from django.apps import apps -from django.http.response import Http404 +from django.http import Http404 from wagtail.admin.views.bulk_action.registry import bulk_action_registry as registry @@ -9,4 +9,4 @@ def index(request, app_label, model_name, action): action_class = registry.get_bulk_action_class(app_label, model_name, action) if action_class is not None: return action_class(request, model).dispatch(request) - return Http404() + raise Http404