neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
260 stars 221 forks source link

BUG: Publishing individual nodes is impossible when contents were created on a deleted document #4997

Open grebaldi opened 3 months ago

grebaldi commented 3 months ago

Problem description

It is possible for editors to get trapped in an inescapably broken workspace state by trying to publish a change set that contains both the creation of a document node and the deletion of that same node.

Steps to reproduce:

  1. Create a document
  2. Create a content node on that document
  3. Delete the document
  4. Can't publish (via the UI)

The exception being thrown is: #1541678486: Node aggregate "..." does currently not exist. This happens during the handling of command CreateNodeAggregateWithNodeAndSerializedProperties.

If an attempt has been made to publish this change set via the UI, the workspace is now broken. It cannot be published, discarded or even rebased via the UI. The only escape-hatch is the CLI:

./flow workspace:discard --force [workspace-name]

If you only take the first 3 steps, it is possible to publish the changes via CLI:

./flow workspace:publish [workspace-name]

The problem is limited to PublishIndividualNodesFromWorkspace and DiscardIndividualNodesFromWorkspace.

Once the publishing attempt via the UI has been made, ./flow workspace:publish ceases to work as well.

Notes on solution

@kitsunet noted in Slack:

shouldn't these steps result in no changes? given that you create the node(s) and delete them again?

Indeed, the ChangeProjection currently only flags the respective change records as both created and deleted. It should be possible to remove the change record instead, if it has been flagged as created and a deletion comes in.