Resubmitting an edited snippet after requested changes starts review against its previous revision
Resubmitting an edited snippet after changes are requested starts review against its previous revision
A native snippet workflow can restart a rejected task using the revision from before the author's changes, even though the same edit/resubmit request saved a new latest revision. This is reproducible on Wagtail 7.4.3 with Django 6.0.8, Python 3.14 and PostgreSQL. The corresponding page workflow uses the new revision.
Reproduction
Use a normal registered snippet with the documented mixin order. The minimal model shape below describes the required native features; the executed regression uses our Measure model with these same mixins and the ordinary SnippetViewSet add/edit/workflow-action views, not a standalone run of this reduced model:
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.models import DraftStateMixin, LockableMixin, RevisionMixin, WorkflowMixin
from wagtail.snippets.models import register_snippet
@register_snippet
class Definition(WorkflowMixin, DraftStateMixin, LockableMixin, RevisionMixin, models.Model):
name = models.CharField(max_length=100)
definition = models.TextField()
panels = [FieldPanel("name"), FieldPanel("definition")]
def __str__(self):
return self.nameSet WAGTAIL_WORKFLOW_REQUIRE_REAPPROVAL_ON_EDIT = True. Through native Wagtail
workflow configuration, assign this snippet model a workflow with two
GroupApprovalTask stages: Review (Reviewer group), then Release (Publisher group).
Use separate users: Author with add/change snippet permission, Reviewer with
change permission and Review task membership, Publisher with change/publish
permission and Release task membership. Each has access_admin.
- As Author, create a snippet with definition
DRAFT DEFINITIONand submit it. This is the native add-form POST withaction-submit=1. It creates revision R1 and an in-progress Review task for R1. - As Reviewer, choose Request changes, supplying a comment through the native
workflow action endpoint. The workflow becomes
needs_changes. - As Author, GET the native edit form, change the definition to
REVISED AFTER FEEDBACK, then choose Resubmit to Review. The edit-form POST includes the changed field andaction-submit=1. - Reload the model and workflow/task from the database, rather than inspecting objects left over from the request:
obj = Definition.objects.get(pk=snippet_id)
state = obj.current_workflow_state # queries the active WorkflowState
assert state.status == state.STATUS_IN_PROGRESS
assert state.current_task_state.revision_id == obj.latest_revision_idExpected: the resumed task uses the newly saved revision R2. Actual: it still uses R1. In our captured regression, the newly queried task revision was 126, while the freshly reloaded snippet's latest revision was 127. The strict assertion fails; no cache refresh or local lifecycle override is applied in the application.
Subsequent approvals
A separate native-HTTP regression continues the workflow after this mismatch. With reapproval enabled, Reviewer approval of the stale R1 task restarts Review again, now on R2. A second Reviewer approval advances to Release on R2; Publisher approval then publishes R2. The test confirms the new revision has both expected approvers and that the snippet remains unpublished until the final release.
We have not observed premature publication. The defect is that resubmission initially identifies the wrong reviewed revision and requires an unnecessary extra Review cycle. This report does not claim behavior when reapproval is turned off.
Source trace
In 7.4.3:
CreateEditViewOptionalFeaturesMixin.get_available_actionscalls the cachedself.workflow_state.user_can_cancel(...)before saving.WorkflowState.user_can_cancelaccesses and caches that state's genericcontent_object.- The form saves the new revision, then
submit_actionresumes the same workflow-state instance. Task.startobtains the new task's revision fromworkflow_state.content_object.get_latest_revision(), which reads the stale snippet object's cached latest-revision relationship.
The documented mixin order matches the model. The before-edit hook runs before the save; the after-edit hook runs after the workflow action. No app hook, copied view method, monkeypatch or vendor change is part of the reproduction.
Source-only checks of v8.0 and main (705dd6794d03c8e2c94eae5cc434b42f340101fb)
found the same cached-state resume call; v8.0 also retains the preceding
user_can_cancel read and Task.start revision lookup. Those versions were not
executed, so this is not a claim of a reproduced failure on them. Searches for
snippet resubmit, workflow stale revision, and workflow-state resume did not
find an existing matching issue.
Source: wagtail/wagtail