Get-PnPSiteTemplate throws: The given key was not present in the dictionary.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 259
- Forks
- 161
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
Description
Hey, I tried to create a template from a modern communication site using Get-PnPSiteTemplate and received the error below. Would appreciate any help! I am using the latest PnP Version.
PS C:\Windows\system32> Get-PnPSiteTemplate -Schema LATEST -IncludeAllPages -IncludeAllTermGroups -out "C:\Users\XX\Desktop\xxx.xml" -PersistMultiLanguageResources -ErrorAction Continue
Get-PnPSiteTemplate : The given key was not present in the dictionary.
At line:1 char:1
- Get-PnPSiteTemplate -Schema V202103 -IncludeAllPages -IncludeAllTermG ...
-
+ CategoryInfo : WriteError: (:) [Get-PnPSiteTemplate], KeyNotFoundException + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate
PS C:\Windows\system32> Get-PnPException
Message : The given key was not present in the dictionary.
Stacktrace : at System.Text.Json.JsonElement.GetProperty(String propertyName)
at PnP.Core.Model.SharePoint.PageWebPart.FromHtml(IElement element)
at PnP.Core.Model.SharePoint.Page.LoadFromHtml(String html, String pageHeaderHtml)
at PnP.Core.Model.SharePoint.Page.d__126.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PnP.Core.Model.SharePoint.Page.d__98.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PnP.Core.Model.SharePoint.Web.d__296.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.SharePoint.Client.PageExtensions.d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.SharePoint.Client.PageExtensions.LoadClientSidePage(Web web, String pageName)
at PnP.Framework.Provisioning.ObjectHandlers.Utilities.ClientSidePageContentsHelper.ExtractClientSidePage(Web web, ProvisioningTemplate template,
ProvisioningTemplateCreationInformation creationInfo, PnPMonitoredScope scope, PageToExport page)
at PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePageContents.ExtractObjects(Web web, ProvisioningTemplate template,
ProvisioningTemplateCreationInformation creationInfo)
at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemplate(Web web, ProvisioningTemplateCreationInformation
creationInfo)
at PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate.ExtractTemplate(XMLPnPSchemaVersion schema, String path, String packageName,
ExtractConfiguration configuration)
at PnP.PowerShell.Commands.Provisioning.Site.GetSiteTemplate.ExecuteCmdlet()
at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord()
ScriptLineNumber : 1
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 with Get-PnPSiteTemplate and the stack-trace entry point PnP.Core.Model.SharePoint.PageWebPart.FromHtml, then follow how Page.LoadFromHtml handles the modern communication site pages. Reproduce the command with the listed options and confirm that template extraction completes without the KeyNotFoundException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100