Provisioning DefaultDocuments in folders in DocumentSets causes duplicated content
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 259
- Forks
- 161
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Description
When using the PnP Provisioning engine to provision Document Sets with DefaultDocuments (aka Default Content) in subfolders, each default document living in a subfolder will be duplicated. Subsequent runs of the provisioning template will add 2 instances of each file every run. Note that I have reproduced this using PnP.PowerShell, but it is a pnpframework issue.
Steps to reproduce
The simplest way to reproduce this issue is to test through PnP.PowerShell with a SiteTemplate. I've created a minimal testcase which you find attached here: TestCase-DocumentSet.zip
- Download and uncompress the testcase to a folder on your machine
- Pick an existing site, or create a new site. Can be a group or communication site, does not matter
- Run the provisioning engine with the template.xml as input, if you are testing this using PnP.PowerShell you can run the following
Connect-PnPOnline -Url <url to test site> -Interactive
Set-PnPSite -NoScriptSite $false # required in order to provision DefaultDocuments
Invoke-PnPSiteTemplate -Path ./template.xml
Set-PnPSite -NoScriptSite $true
Expected result
Under default content in the content type, I expect to find two (2) files,
Folder 1/doc1.docx
Folder 2/doc2.docx
Actual results
Each file is uploaded twice

Observations
The test for duplicate defaultdocuments checks the file by name. The condition d.Name != doc.Name will always return true if the Default Document in the template is defined like so
<pnp:DefaultDocument Name="Folder 1/doc1.docx" ContentTypeID="0x0101" FileSourcePath="./doc1.docx" />
Since the documentSetTemplate (i.e. CSOM/pnpframework object) will always have the Name be the filename without the path.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectContentType.cs around the duplicate default document check at line 387. Reproduce the issue with the attached TestCase-DocumentSet.zip and template.xml, focusing on DefaultDocument entries whose Name includes a subfolder path. Done means repeated provisioning no longer duplicates Folder 1/doc1.docx or Folder 2/doc2.docx.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100