Crash when bulk publishing pages that include an alias without a `latest_revision`
Author: mcoconnorCreated Oct 4, 2023Updated Sep 30, 2026
Labelstype:Bugcomponent:Page aliascomponent:Bulk Actionsstatus:Unconfirmed
In a Wagtail site with a long history, I have a number of page aliases where the page.latest_revision is null. I believe that these were aliases that were created through the admin in old versions (around 2.14, but I'm not yet sure exactly where the cutoff was). The site has since been upgraded to 5.1.2, but when a bulk publish operation includes one of these legacy aliases, an unhandled exception is thrown:
RuntimeError: page.save_revision() was called on an alias page. Revisions are not required for alias pages as they are an exact copy of another page.
File "django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "contextlib.py", line 75, in inner
return func(*args, **kwds)
File "django/views/decorators/cache.py", line 62, in _wrapper_view_func
response = view_func(request, *args, **kwargs)
File "wagtail/admin/urls/__init__.py", line 176, in wrapper
return view_func(request, *args, **kwargs)
File "wagtail/admin/auth.py", line 184, in decorated_view
response = view_func(request, *args, **kwargs)
File "wagtail/admin/views/bulk_action/dispatcher.py", line 11, in index
return action_class(request, model).dispatch(request)
File "django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
File "django/views/generic/edit.py", line 153, in post
return self.form_valid(form)
File "wagtail/admin/views/bulk_action/base_bulk_action.py", line 147, in form_valid
num_parent_objects, num_child_objects = self.execute_action(
File "wagtail/admin/views/pages/bulk_actions/publish.py", line 43, in execute_action
revision = page.get_latest_revision() or page.specific.save_revision(
File "wagtail/models/__init__.py", line 1702, in save_revision
raise RuntimeError(This is because in the bulk publish action here: https://github.com/wagtail/wagtail/blob/ea6ca67ae005d6a9195687bf78b7b316e88c3c94/wagtail/admin/views/pages/bulk_actions/publish.py#L43 wagtail attempts to create a revision if no latest revision is found.
Steps to Reproduce
- create a page alias with no
latest_revision(e.g. through a old version of Wagtail) - issue a bulk publish to a set of pages including this alias through the wagtail admin
- observe the crash
Expected behavior: pages bulk publish successfully
- I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no, but I have been able to reproduce the error by clearing the
latest_revisionfield on a alias created in a fresh wagtail install.
Technical details
- Python version: 3.10
- Django version: 4.2.2
- Wagtail version: 5.1.2
- Browser version: any
Possible solution
- Add a data migration to add a
latest_revisionto any aliases that are missing one
Source: wagtail/wagtail