pnp / pnp/pnpframework

PnP.Framework 1.5.0 LoadClientSidePage() Exception

Open
#701 0 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

Below is the code I am using in a .NET Core 3.1 console application.

var clientSidePage = clientContext.Web.LoadClientSidePage(mordernPageName);

For most of the pages, the above code works. For a few pages, it throws an exception. All pages work fine for end users in browsers.

Below is an example of the exception:

Message: '3' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: 0 | BytePositionInLine: 2103.

at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker) at System.Text.Json.Utf8JsonReader.ConsumeNextTokenOrRollback(Byte marker) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, Utf8JsonReader reader, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedBytes) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 json, JsonDocumentOptions options)
at System.Text.Json.JsonDocument.Parse(String json, JsonDocumentOptions options)
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.LoadPageAsync(IList pagesLibrary, IListItem item)
at PnP.Core.Model.SharePoint.Page.LoadPagesAsync(PnPContext context, String pageName)
at PnP.Core.Model.SharePoint.Web.GetPagesAsync(String pageName)
at PnP.Core.Model.SharePoint.Web.GetPages(String pageName)
at Microsoft.SharePoint.Client.PageExtensions.LoadClientSidePage(Web web, String pageName)

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 with PnP.Core.Model.SharePoint.PageWebPart.FromHtml in the stack trace, then follow Page.LoadFromHtml and the LoadClientSidePage call using one of the pages that fails. Reproduce the JSON parsing exception and inspect the page content around byte position 2103. Done means the affected pages load without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.