pnp / modernization

All modernization tooling and guidance
http://aka.ms/sppnp-modernize
MIT License
156 stars 86 forks source link

ConvertTo-PnPClientSidePage - Index was out of range error #37

Closed adamtoad closed 5 years ago

adamtoad commented 5 years ago

Using the ConvertTo-PnPClientSidePage cmdlet is giving me this error. image

Any ideas as to why this might be happening?

jansenbe commented 5 years ago

Hi @adamtoad ,

Would it be possible to provide the wiki content of the failing page? If you can't share this via GitHub then let me know and we'll switch to a private mail conversation.

To get the contents of the page you can use below PowerShell snippet:

Connect-PnPOnline -Url https://yourtenant.sharepoint.com/sites/yoursite
# Plug in the ID of the failing page
$page = Get-PnPListItem -List sitepages -Id 3
$page["WikiField"] > debug.txt
adamtoad commented 5 years ago

Hi @jansenbe ,

Thanks for the response. Unfortunately, the wiki page contains some sensitive content which I cannot provide. Is there anything else I can provide you with that would help?

jansenbe commented 5 years ago

Do you have other pages showing the same issue? Maybe some of these can be shared? Do you see anything special on the page that fails?

jansenbe commented 5 years ago

Hi @adamtoad ,

Getting a stack trace would be useful as well. Can you run Get-PnPException after the error and share those details + the full error message on the screen.

adamtoad commented 5 years ago

Sorry about the delayed response. Here are the contents of one of the failing pages: https://pastebin.com/tnSrvN9A

And here is the stack trace:

Message : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Stacktrace : at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.LastColumnOrder(Int32 row, Int32 col) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.Transform(List`1 webParts) at SharePointPnP.Modernization.Framework.Transform.PageTransformator.Transform(PageTransformation Information pageTransformationInformation) at SharePointPnP.PowerShell.Commands.ClientSidePages.ConvertToClientSidePage.ExecuteCmdlet() at SharePointPnP.PowerShell.Commands.PnPCmdlet.ProcessRecord() ScriptLineNumber : 28

jansenbe commented 5 years ago

Was able to simulate the error and will work on a fix. Thx for sharing the repro.

jansenbe commented 5 years ago

Hi @adamtoad,

A fix has been checked in to the dev branch (https://github.com/SharePoint/sp-dev-modernization/commit/6cd4e562725b81fb063e1d996b6488ea544e947d) and will appear in the February version of the Modernization nuget package and PnP Powershell.

The problem was somehow that your wiki HTML seems to be a combination of multiple wiki pages, might have been generated due to copy-paste across pages in the past. The added check will avoid processing the same content multiple times which will then, later on, prevent the index mismatch errors.

Looking at your page you'll see that after transformation you've nested tables as there's a "hidden" table in your HTML structure hosting the other tables. You can either fix this in your source wiki page by creating a new page and copying the needed sections or alternatively manually create the modern version of the page.

marcdayton commented 5 years ago

Hi, In know this is closed, but am getting the same error using SharePointPnPPowerShellOnline version 3.6.1902.2 It is happening on random Home.aspx pages and a few random custom pages that are very generic. The Home.aspx pages all appear different. A couple that error have an unsupported web part like calendar, others don't.

Here is the error: `+ ... ConvertTo-PnPClientSidePage -Identity $page.FieldValues[" ...

Here is the stack trace Message : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Stacktrace : at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.LastColumnOrder(Int32 row, Int32 col) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.Transform(List1 webParts) at SharePointPnP.Modernization.Framework.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation) at SharePointPnP.PowerShell.Commands.ClientSidePages.ConvertToClientSidePage.ExecuteCmdlet() at SharePointPnP.PowerShell.Commands.PnPCmdlet.ProcessRecord()`

Here is the Wiki Page content

`

Canada Information Services

 

        <span id="layoutsData" style="display&#58;none;">true,false,2</span></div>

`

Any help would be appreciated.