question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
heinrich-ulbrichtcommented, Sep 28, 2022

I pushed 2 changes to my forks that in combination hopefully fix broken pages. The proposed solution has two parts:

PnP.Framework:

  • detect when a page (whose file exists) is broken (because of missing basic field values)
  • trigger the creation of a “new” page in those cases (ultimately via PnP.Core functions; PnP.Core is smart enough to detect the existing page file and will update it; BUT: we need a modification there)

PnP.Core:

  • modify the page creation code to also initialize “basic” fields for existing pages (so far those were only initialized for really new pages), but only if those fields are empty - which they are for our broken pages

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.

1reaction
heinrich-ulbrichtcommented, Sep 28, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NoComponentId error when open a migrated page form ...
Observed that migrated pages created in only specific Page library regardless of where the source page is existing despite it should be created ......
Read more >
SharePoint 2019 Installation Error - NoComponentID
I am installing a SharePoint 2019 on a single server for development purposes. I am using AutoSPInstaller to do the install. After running...
Read more >
NoComponentId error while creating ClientSidePage in ...
_ClientContext.ExecuteQuery();. The page is shown inside the Site Pages. But when I try to open it, following error I get on the browser:....
Read more >
M365 – SharePoint Online – Resolving exception “ ...
M365 – SharePoint Online – Resolving exception “NoComponentId” while creating new client side page in Site Pages Library using CSOM.
Read more >
OSGi Service Platform Enterprise Specification
An implementation that does not satisfy limitations (i)-(ii) is not considered an implementation of the Specification, does not receive the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found