"Detected the item with ID existed on disk in more than in one place" error in Sitecore CLI console


Description

The Sitecore Command Line Interface (CLI) serialization commands might fail if different "includes" nodes reference to nested paths in a module's configuration file. 

For example, when executing the command:

dotnet sitecore ser pull 

An error similar to the following can appear in the console (note that it might be necessary to run the command 2 times to get it):

Detected the item with ID a2b9c39c-9a19-4067-910a-90c84f93ae9d existed on disk in more than one place (C:\inetpub\wwwroot\sc10.2sc.dev.local\src\serialization\master\sitecore\content\test\TEST.yml + more). Use the validate command to diagnose the problem.

The issue affects CLI starting from 3.0.0 version.

Solution

As a solution, consider avoiding nested names in "includes".

 For example, instead of:

{ 
    "namespace": "test",
    "items": {
        "includes": [
            {
                "name": "A/B/C",
                ...
            },
            {
                "name": "A/B/C/D", // <---- will not work correctly
              ...
            }
        ]
    }
}

use:


    "namespace": "test",
    "items": {
        "includes": [
            {
                "name": "A/B/C",
                ...
            },
            {
                "name": "X/Y/Z/D",  // <---- will work correctly
                ...
            }
        ]
    }
}