Custom pages occasionally get provisioned as corrupted (`NoComponentId` error)
See original GitHub issueOccasionally when provisioning out a page, the resultant page is corrupted. This crashes the provisioning process. Attempting to re-apply the template crashes at the same point with a null reference exception:
Object reference not set to an instance of an object.
Source = PnP.FrameworkTargetSite = Void CreatePage(Microsoft.SharePoint.Client.Web, PnP.Framework.Provisioning.Model.ProvisioningTemplate, PnP.Framework.Provisioning.ObjectHandlers.TokenParser, PnP.Framework.Diagnostics.PnPMonitoredScope, PnP.Framework.Provisioning.Model.BaseClientSidePage, System.String, Microsoft.SharePoint.Client.List, Int32 ByRef, System.Collections.Generic.List`1[System.String])
HResult = -2147467261StackTrace =
at PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePages.CreatePage(Web web, ProvisioningTemplate template, TokenParser parser, PnPMonitoredScope scope, BaseClientSidePage clientSidePage, String pagesLibrary, List pagesLibraryList, Int32& currentPageIndex, List`1 preCreatedPages)
at PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePages.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation)
at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser)
at MKS.ClientPortalFunctions.Functions.SiteProvisioning.OnTeamCreated.ApplyTemplate(String siteUrl, Stream templateStream) in D:\a\1\s\functions\siteProvisioning\OnTeamCreated.cs:line 183
Attempting to open the page shows a “Something went wrong” error page citing NoComponentId
with no further information.
This has happened maybe 150 times out of around 15,500. Deleting a site with the corrupted page and reprovisioning it has always resolved it. Both of these point to it looking like a race condition maybe?
We always apply the template to freshly created team sites using the out of the box team site template, so the sites have had no visitors or customizations to interfere with anything.
The below is a shortned version of the template we’re using, containing only the full page that gets corrupted (minus the custom web part properties). The page contains four web parts:
- 1x OOTB text
- 2x custom web part
- 1x another custom web part
Minimal template
<?xml version="1.0" encoding="utf-8"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.10.0.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c"/>
<pnp:Templates ID="CONTAINER-TEMPLATE-BD216736552340C2B5B3FE8BD9291376">
<pnp:ProvisioningTemplate ID="TEMPLATE-BD216736552340C2B5B3FE8BD9291376" Version="1" BaseSiteTemplate="GROUP#0"
Scope="RootSite">
<pnp:ClientSidePages>
<pnp:ClientSidePage PromoteAsNewsArticle="false" PromoteAsTemplate="false" Overwrite="true"
Title="Administration" ThumbnailUrl="" PageName="Administration.aspx">
<pnp:Header Type="Custom" ServerRelativeImageUrl="/_LAYOUTS/IMAGES/SLEEKTEMPLATEIMAGETILE.JPG"
LayoutType="NoImage" ShowTopicHeader="false" ShowPublishDate="false" TopicHeader=""
AlternativeText="" Authors="[]" AuthorByLine="[]" AuthorByLineId="-1"/>
<pnp:Sections>
<pnp:Section Order="1" Type="OneColumn">
<pnp:Controls>
<pnp:CanvasControl WebPartType="Text" ControlId="77936784-91c8-44ae-909d-6064f32cf707"
Order="1" Column="1">
<pnp:CanvasControlProperties>
<pnp:CanvasControlProperty Key="Text"
Value="<div><div><span> INSTRUCTION TEXT </span></div></div>"/>
</pnp:CanvasControlProperties>
</pnp:CanvasControl>
</pnp:Controls>
</pnp:Section>
<pnp:Section Order="2" Type="ThreeColumn">
<pnp:Controls>
<pnp:CanvasControl WebPartType="Custom"
JsonControlData="{"id": "d2482049-dc6d-4275-84ae-8d4ff2e53e70", "instanceId": "b6973dc3-d6d0-42cd-a52e-ecdaa19fc4e5", "title": "Flow Trigger Form", "description": "Triggers HTTP Flows and Power Apps with form values.", "dataVersion": "1.0", "properties": {}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}"
ControlId="d2482049-dc6d-4275-84ae-8d4ff2e53e70" Order="1"
Column="1"/>
<pnp:CanvasControl WebPartType="Custom"
JsonControlData="{"id": "d2482049-dc6d-4275-84ae-8d4ff2e53e70", "instanceId": "94addb58-d60f-47ab-8af5-8c4456030d08", "title": "Flow Trigger Form", "description": "Triggers HTTP Flows and Power Apps with form values.", "dataVersion": "1.0", "properties": {}, "serverProcessedContent": {"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}}, "dynamicDataPaths": {}, "dynamicDataValues": {}}"
ControlId="d2482049-dc6d-4275-84ae-8d4ff2e53e70" Order="1"
Column="2"/>
<pnp:CanvasControl WebPartType="Custom"
JsonControlData="{"id":"4929fe9a-5e1a-427a-9e67-02a8eefe94da","instanceId":"a05a9e0a-2dc3-4e2f-a334-164ac8508019","title":"CORE Group Management","description":"View, add and remove users from SharePoint groups.","dataVersion":"1.0","properties":{},"serverProcessedContent":{"htmlStrings":{},"searchablePlainTexts":{},"imageSources":{},"links":{}},"dynamicDataPaths":{},"dynamicDataValues":{}}"
ControlId="4929fe9a-5e1a-427a-9e67-02a8eefe94da" Order="1"
Column="3"/>
</pnp:Controls>
</pnp:Section>
<pnp:Section Order="3" Type="ThreeColumn"/>
<pnp:Section Order="4" Type="ThreeColumn"/>
</pnp:Sections>
</pnp:ClientSidePage>
</pnp:ClientSidePages>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>
Platform: Windows Server (Azure Functions v4 serverless environment, NET 6) Version: 1.10.0.0
If you need any more info, please let me know.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
I pushed 2 changes to my forks that in combination hopefully fix broken pages. The proposed solution has two parts:
PnP.Framework:
PnP.Core:
This proposed solution works without deleting the broken page (which could cause side effects) and is based on the assumption that filling in those missing field values is enough to make the page work again. Kind of an auto-repair mode.
Let’s see how this works out. I’ll be testing those changes to see if this keeps up.
That is my premise, yes. E.g. not setting certain fields in a second provisioning run will normally preserve their values from the first run. It would help to know the cause of the missing ID. Maybe such a broken page can only happen when newly creating it and setting any metadata on this new page (in the same run) will fail also. But in this case the engine should probably throw an error immediately and not wait for a second run to fail. Because currently it seems there would be a lingering broken page, waiting for the user - or the second provisioning run - to discover it.