pnp / pnp/pnpframework

ClientSitePage provisioning fails with "PnP.Core.ClientException: Property ServerRelativeUrl was not yet loaded"

Open
#716 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

Category

  • Bug

Describe the bug

Applying templates with ClientSidePages sometimes fails with PnP.Core.ClientException: Property ServerRelativeUrl was not yet loaded.

Steps to reproduce

Unfortunately I only have a log and no specific steps to reproduce since the error happens in a complex provisioning scenario. But I have a call stack.

We are provisioning ClientSitePages via provisioning templates. The following cases are included:

  1. provisioning new pages
  2. updating existing pages
  3. sometimes the provisioning is canceled during page provisioning and those pages later are provisioned/updated again

I'm explicitly mentioning the last two cases since the error kept appearing after once canceling the provisioning and restarting it. Otherwise provisioning of new and updating of existing pages works. Not sure when and why some fail. I hope somebody can read this out of the call stack.

Here's the call stack:

System.AggregateException: One or more errors occurred. (Property ServerRelativeUrl was not yet loaded)
 ---> PnP.Core.ClientError
PnP.Core.ClientException: Property ServerRelativeUrl was not yet loaded
   at PnP.Core.Model.TransientObject.GetValue[T](String propertyName) in /_/src/sdk/PnP.Core/Model/Base/TransientObject.cs:line 136
   at PnP.Core.Model.SharePoint.Folder.get_ServerRelativeUrl() in /_/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/Folder.cs:line 62
   at PnP.Core.Model.SharePoint.Page.GetPageFileAsync(String pageName, IList pagesLibrary) in /_/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs:line 1870
   at PnP.Core.Model.SharePoint.Page.EnsurePageListItemAsync(String pageName) in /_/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs:line 1881
   at PnP.Core.Model.SharePoint.Page.SaveAsync(String pageName) in /_/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs:line 1578
   at PnP.Core.Model.SharePoint.Page.Save(String pageName) in /_/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs:line 1515
   at PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePages.PreCreatePage(Web web, ProvisioningTemplate template, TokenParser parser, BaseClientSidePage clientSidePage, String pagesLibrary, List pagesLibraryList, Int32& currentPageIndex) in /_/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs:line 1080
   at PnP.Framework.Provisioning.ObjectHandlers.ObjectClientSidePages.ProvisionObjects(Web web, ProvisioningTemplate template, TokenParser parser, ProvisioningTemplateApplyingInformation applyingInformation) in /_/src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs:line 64
   at PnP.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.ApplyRemoteTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation provisioningInfo, Boolean calledFromHierarchy, TokenParser tokenParser) in /_/src/lib/PnP.Framework/Provisioning/ObjectHandlers/SiteToTemplateConversion.cs:line 455
   at Microsoft.SharePoint.Client.WebExtensions.ApplyProvisioningTemplate(Web web, ProvisioningTemplate template, ProvisioningTemplateApplyingInformation applyingInformation) in /_/src/lib/PnP.Framework/Extensions/WebExtensions.cs:line 1182

Expected behavior

I expect the error not to happen.

Environment details (development & target environment)

  • SDK version: PnP Core 1.7.0, PnP Framework 1.10.0
  • OS: Windows Server 2012 R2 Standard
  • SDK used in: Console App
  • Framework: .NET Core v6.0.400
  • Browser(s): -
  • Tooling: Visual Studio 2022
Additional context

None

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Page.GetPageFileAsync and EnsurePageListItemAsync in src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs, then inspect ObjectClientSidePages.PreCreatePage in src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectClientSidePages.cs. Use the reported scenarios—new pages, existing pages, and canceled provisioning—as reproduction targets. Done means ClientSitePage provisioning no longer raises the unloaded ServerRelativeUrl exception.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.