You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The VersionMismatchError exception will be raised if ManualPublishTask#version_number does not match Manual#version_number retrieved from the database when PublishManualWorker#perform takes a ManualPublishTask off the "queue" and invokes Manual::PublishService#call.
As we are now queueing manuals for publishing we need to protect against changes happening between an editor clicking Publish and the worker actually performing the publish.
This suggests to me that if I do the following, I should see the VersionMismatchError exception being raised:
Disable PublishManualWorker
Publish manual
See that manual has been queued for publishing, but not actually published
Edit manual
Makes some changes to the manual
Save manual as draft
Enable PublishManualWorker
Wait for the relevant ManualPublishTask to be processed
However, I do not see the exception and the latest content is saved and published to the Publishing API. I don't think this is what was intended.
I think the problem is that ManualRecord#new_or_existing_draft_edition does not build a new edition if the manual is in the "draft" state. The manual will be in the "draft" state until the relevant ManualPublishTask is processed by PublishManualWorker and so no new edition will be built until the manual is actually published. Thus Manual#version_number will not be incremented and the condition in Manual::PublishService#call will always be true and the exception will never be raised.
Note that all of the tests around this supposed protection mechanism are stubbing the raising of the exception and not exercising the check in a realistic context which explains why we don't see any tests failing.
We could fix this by discriminating between a draft and a draft awaiting publication, but I have a feeling this might be quite complicated. It might be simpler to head things off at the pass by preventing editing of a manual which is a draft awaiting publication.
The text was updated successfully, but these errors were encountered:
The
VersionMismatchError
exception will be raised ifManualPublishTask#version_number
does not matchManual#version_number
retrieved from the database whenPublishManualWorker#perform
takes aManualPublishTask
off the "queue" and invokesManual::PublishService#call
.This commit note says:
This suggests to me that if I do the following, I should see the
VersionMismatchError
exception being raised:PublishManualWorker
PublishManualWorker
ManualPublishTask
to be processedHowever, I do not see the exception and the latest content is saved and published to the Publishing API. I don't think this is what was intended.
I think the problem is that
ManualRecord#new_or_existing_draft_edition
does not build a new edition if the manual is in the "draft" state. The manual will be in the "draft" state until the relevantManualPublishTask
is processed byPublishManualWorker
and so no new edition will be built until the manual is actually published. ThusManual#version_number
will not be incremented and the condition inManual::PublishService#call
will always betrue
and the exception will never be raised.Note that all of the tests around this supposed protection mechanism are stubbing the raising of the exception and not exercising the check in a realistic context which explains why we don't see any tests failing.
We could fix this by discriminating between a draft and a draft awaiting publication, but I have a feeling this might be quite complicated. It might be simpler to head things off at the pass by preventing editing of a manual which is a draft awaiting publication.
The text was updated successfully, but these errors were encountered: