pnpframework icon indicating copy to clipboard operation
pnpframework copied to clipboard

Custom pages occasionally get provisioned as corrupted (`NoComponentId` error)

Open JakeStanger opened this issue 1 year ago • 0 comments

Occasionally 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="&lt;div&gt;&lt;div&gt;&lt;span&gt; INSTRUCTION TEXT &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;"/>
                                    </pnp:CanvasControlProperties>
                                </pnp:CanvasControl>
                            </pnp:Controls>
                        </pnp:Section>
                        <pnp:Section Order="2" Type="ThreeColumn">
                            <pnp:Controls>
                                <pnp:CanvasControl WebPartType="Custom"
                                                   JsonControlData="{&quot;id&quot;: &quot;d2482049-dc6d-4275-84ae-8d4ff2e53e70&quot;, &quot;instanceId&quot;: &quot;b6973dc3-d6d0-42cd-a52e-ecdaa19fc4e5&quot;, &quot;title&quot;: &quot;Flow Trigger Form&quot;, &quot;description&quot;: &quot;Triggers HTTP Flows and Power Apps with form values.&quot;, &quot;dataVersion&quot;: &quot;1.0&quot;, &quot;properties&quot;: {}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{},&quot;links&quot;:{}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}"
                                                   ControlId="d2482049-dc6d-4275-84ae-8d4ff2e53e70" Order="1"
                                                   Column="1"/>
                                <pnp:CanvasControl WebPartType="Custom"
                                                   JsonControlData="{&quot;id&quot;: &quot;d2482049-dc6d-4275-84ae-8d4ff2e53e70&quot;, &quot;instanceId&quot;: &quot;94addb58-d60f-47ab-8af5-8c4456030d08&quot;, &quot;title&quot;: &quot;Flow Trigger Form&quot;, &quot;description&quot;: &quot;Triggers HTTP Flows and Power Apps with form values.&quot;, &quot;dataVersion&quot;: &quot;1.0&quot;, &quot;properties&quot;: {}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{},&quot;links&quot;:{}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}"
                                                   ControlId="d2482049-dc6d-4275-84ae-8d4ff2e53e70" Order="1"
                                                   Column="2"/>
                                <pnp:CanvasControl WebPartType="Custom"
                                                   JsonControlData="{&quot;id&quot;:&quot;4929fe9a-5e1a-427a-9e67-02a8eefe94da&quot;,&quot;instanceId&quot;:&quot;a05a9e0a-2dc3-4e2f-a334-164ac8508019&quot;,&quot;title&quot;:&quot;CORE Group Management&quot;,&quot;description&quot;:&quot;View, add and remove users from SharePoint groups.&quot;,&quot;dataVersion&quot;:&quot;1.0&quot;,&quot;properties&quot;:{},&quot;serverProcessedContent&quot;:{&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{},&quot;links&quot;:{}},&quot;dynamicDataPaths&quot;:{},&quot;dynamicDataValues&quot;:{}}"
                                                   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.

JakeStanger avatar Sep 12 '22 13:09 JakeStanger