Fix Resolve-PnPFolder exceeding the list view threshold on large libraries - #5411
Open
svermaak wants to merge 1 commit into
Open
Fix Resolve-PnPFolder exceeding the list view threshold on large libraries#5411svermaak wants to merge 1 commit into
svermaak wants to merge 1 commit into
Conversation
…aries Resolve-PnPFolder delegated to PnP Framework's EnsureFolderPath, which enumerates the entire Folders collection of every path segment. On folders holding more than 5000 items that query exceeds the list view threshold. Replaced with direct GetFolderByServerRelativePath probes (loading only Exists) and Folders.AddUsingPath for missing segments, so no folder collection is ever enumerated. Fixes pnp#2286
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change
Related issue
Fixes #2286 (and the earlier regression of #1438)
What is in this Pull Request
Resolve-PnPFolderdelegated to PnP Framework'sWeb.EnsureFolderPath, which checks every path segment by loading the entireFolderscollection of the parent folder and iterating it to find the child. That collection load is a list query, so as soon as any folder in the path resides in a scope holding more than 5000 items, SharePoint rejects it with "The attempted operation is prohibited because it exceeds the list view threshold."This PR resolves the folder path inside the cmdlet itself using direct path addressing, the same threshold-safe pattern already used by
Get-PnPFolder,Copy-PnPFileandMove-PnPFile:GetFolderByServerRelativePath(ResourcePath.FromDecodedUrl(...))loading onlyExists. When the folder already exists this is a single round trip (the previous implementation issued one query per path segment).Folders.AddUsingPath, which performs an add without enumerating the collection.-Includesretrieval expressions are still honored on the returned folder.No folder or item collection is ever enumerated, so the list view threshold no longer applies regardless of folder size.