Generated code in Data folder can't getWorkspace() of a node and throws, making publishing impossible

When trying to edit simple text content or properties in the backend, the publish XHR fails with code 500. I managed to hunt down the exact line that fails. It is in the generated file
“/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_ContentRepository_Domain_Model_Workspace.php”:

 protected function moveNodeVariantsInOtherWorkspaces($nodeIdentifier, $targetPath, Workspace $sourceWorkspace, Workspace $targetWorkspace): void
    {
        $nodeDataVariants = $this->nodeDataRepository->findByNodeIdentifier($nodeIdentifier);
        /** @var NodeData $nodeDataVariant */
        foreach ($nodeDataVariants as $nodeDataVariant) {
            if (
                $nodeDataVariant->getWorkspace()->getBaseWorkspace() === null ||
                $nodeDataVariant->getPath() === $targetPath ||
                $nodeDataVariant->getWorkspace() === $sourceWorkspace ||
                $nodeDataVariant->getWorkspace() === $targetWorkspace
            ) {
                continue;
            }

            $shadowNodeData = $this->nodeDataRepository->findOneByMovedTo($nodeDataVariant);
            if ($shadowNodeData === null) {
                $nodeDataVariant->setPath($targetPath);
            }
        }
    }

The line $nodeDataVariant->getWorkspace()->getBaseWorkspace() === null fails, since the workspace of the node data is null.
This issue is too deep within the Neos framework for me to solve it by myself. We had a little back and forth with node dimensions, since we didn’t know one needs to specify one in Settings.yaml for a custom site. However, this issue is about workspaces so I don’t think that’s the cause. Has any of you an idea what could be the issue?

Neos Version: 8.3 (Development context)

It think you might have some errors with the configuration and your content repository if you say you tried with dimensions.
You don’t need dimensions if your don’t build f.e. a multi lingual site.

So I think you might have some broken nodes in your content repository and should try node:repair —dry-run to see if neos detects some problems.

1 Like

Thanks, that helps. Besides some orphans and unstable IDs there are several nodes that refer to an invalid workspace. The message is:
Node /sites/…/node-k4bz2whzgzt70/node-0rxrnok9pozpo/node-xtzs3vcami2re/node-gje5fn7q082t1/main/node-hgtmc9s1mmqqj (identifier: cdbf99dd-46fc-438b-a8e0-666bd3546034) refers to an invalid workspace: null
Does anyone of you know how this happens or how to save the content?