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.

Page.cs SaveAsync fails on a big SitePages list

See original GitHub issue

Category

  • Bug

Describe the bug

I use PnP Provisioning to create Pages in the SitePages library. It currently fails with a nullreference exception, on my production sitecollection that has more than 5000 items in there. Same code runs on a site collection with less files in the library, all works.

Steps to reproduce

  1. Have a SitePages list with >5000 items (mine has 5950)
  2. Run a PnP Provisioning script that creates a page
  3. Have it fail 😉

Expected behavior

Page should be created without nullreference.

Additional context

Problem exists in this method: https://github.com/pnp/pnpcore/blob/189ca6153db0e77e9e4a2cbf12d93a7945ee5521/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs#L1421

And manifests at this point, where PageListItem is null https://github.com/pnp/pnpcore/blob/189ca6153db0e77e9e4a2cbf12d93a7945ee5521/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs#L1518

My 2 cents

You are doing this: https://github.com/pnp/pnpcore/blob/189ca6153db0e77e9e4a2cbf12d93a7945ee5521/src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs#L1761-L1779

As far as I can see, it essentially does a big query to SharePoint to fetch ALL matching items. The code before already established a mypagename.aspx which is unique in that specific list. I don’t see why we need to query to full list here just to get the ListItem associated with the file. Can’t it be simpler like

                    file = list.ParentWeb.GetFileByServerRelativeUrl(@"path\to\mypagename.aspx");
                    clientContext.Load(docSet.ListItemAllFields);
                    await clientContext.ExecuteQueryAsync();

Using GetFileByServerRelativeUrl does not trip over a big list.

Also, I might be totally looking at this wrong. So any other insights are appreciated. My code is failing in production so I can spend time on this to make it better if someone can provide directions.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jansenbecommented, Apr 7, 2021

@YannickRe : Your change was merged, all the tests did succeed. Thanks!

0reactions
YannickRecommented, Apr 6, 2021

@jansenbe You’ve got mail!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with pages: an introduction | PnP Core SDK
PnP Core SDK does not support editing those classic pages, but there's extensive support ... method and persist the created page via the...
Read more >
Exception in building package · Issue #283 · microsoft/Win2D
Hello. I got an exception when I tried to build this package. How to solve it? I have VS 2015 Update 1. Merging...
Read more >
Working with web parts and text parts | PnP Core SDK
The AvailablePageComponentsAsync method is a call that takes quite some time and returns a large chunk of data. It's best to do this...
Read more >
Use Microsoft.Playwright.Core.Frame.QuerySelectorAsync ...
Use the QuerySelectorAsync method in Microsoft.Playwright.Core package in your next Playwright-dotnet project with LambdaTest Automation Testing Advisor.
Read more >
Help with async await
Coroutines are just a huge hack; IEnumerator was not designed as a way to run asynchronous code; it was designed to enumerate a...
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