pnp / modernization

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

[BUG] UrlMappingFile parameter breaks modernization process and modern page is not created #550

Closed antso77 closed 3 years ago

antso77 commented 3 years ago

Problem Area

[x ] Page Transformation: Error during the use of page transformation from PnP PowerShell [ ] Page Transformation: Error during the use of page transformation from .Net [ ] Page Transformation: Page is not looking correct after transformation [ ] Modernization Scanner: something went wrong...

Expected or Desired Behavior

Running command

ConvertTo-PnPClientSidePage -Identity "default.aspx" -PublishingPage -Overwrite -PublishingTargetPageName "consulting.aspx" -TargetConnection $targetConnection -PageLayoutMapping "C:\MigrationTool\custompagelayoutmapping.xml" -SkipDefaultUrlRewriting -UrlMappingFile C:\MigrationTool\urls.csv -LogType Console -LogVerbose

When converting page, data mapped in UrlMappingFile should update urls in wikitext and quick links webpart. Not working even with only one line in file, like this: /sites/intranet/consulting,/sites/intra-consulting

Working great without -UrlMappingfile parameter, like:

ConvertTo-PnPClientSidePage -Identity "default.aspx" -PublishingPage -Overwrite -PublishingTargetPageName "consulting.aspx" -TargetConnection $targetConnection -PageLayoutMapping "C:\MigrationTool\custompagelayoutmapping.xml" -SkipDefaultUrlRewriting -LogType Console -LogVerbose

Observed Behavior

Error in console log when running command:

..... [Content Transform] Transforming web parts [Web Part Mapping] Web Part:'WikiText' of type 'SharePointPnP.Modernization.WikiTextPart' is being transformed Debug: [Web Part Mapping] Processing selector functions Source: Void Transform(System.Collections.Generic.List1[SharePointPnP.Modernization.Framework.Entities.WebPartEntity]) Error: [Web Part Mapping] An error occurred processing functions - Exception has been thrown by the target of an invocation. Error: Exception has been thrown by the target of an invocation. StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at SharePointPnP.Modernization.Framework.Functions.BaseFunctionProcessor.ExecuteMethod(Object functionClassInstance, FunctionDefinition functionDefinition, MethodInfo methodInfo) at SharePointPnP.Modernization.Framework.Functions.FunctionProcessor.ExecutePropertyFunctions(String[] functionsToProcess, WebPart webPartData, WebPartEntity webPart, Property property) at SharePointPnP.Modernization.Framework.Functions.FunctionProcessor.Process(WebPart& webPartData, WebPartEntity webPart) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.Transform(List1 webParts) Error: [Summary] A critical error occurred - transformation did not complete Error: Exception has been thrown by the target of an invocation. StackTrace: at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at SharePointPnP.Modernization.Framework.Functions.BaseFunctionProcessor.ExecuteMethod(Object functionClassInstance, FunctionDefinition functionDefinition, MethodInfo methodInfo) at SharePointPnP.Modernization.Framework.Functions.FunctionProcessor.ExecutePropertyFunctions(String[] functionsToProcess, WebPart webPartData, WebPartEntity webPart, Property property) at SharePointPnP.Modernization.Framework.Functions.FunctionProcessor.Process(WebPart& webPartData, WebPartEntity webPart) at SharePointPnP.Modernization.Framework.Transform.ContentTransformator.Transform(List`1 webParts) at SharePointPnP.Modernization.Framework.Publishing.PublishingPageTransformator.Transform(PublishingPageTransformationInformation publishingPageTransformationInformation)

Steps to Reproduce

Running command with latest SharePointPnPPowerShellOnline module (3.26.2010.0) $sourceConnection = Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/intranet/consulting -ReturnConnection -Credentials $credentials $targetConnection = Connect-PnPOnline -Url https://tenant.sharepoint.com/sites/intra-consulting -ReturnConnection -Credentials $credentials ConvertTo-PnPClientSidePage -Identity "default.aspx" -Connection $sourceConnection -PublishingPage -Overwrite -PublishingTargetPageName "consulting.aspx" -TargetConnection $targetConnection -PageLayoutMapping "C:\MigrationTool\custompagelayoutmapping.xml" -SkipDefaultUrlRewriting -UrlMappingFile C:\MigrationTool\urls.csv -LogType Console -LogVerbose

jansenbe commented 3 years ago

Hi @antso77 : Seems like one of the functions throws an error when using the url mapping file. Can you show the url mapping file you're using? Or can you can try to simplify your mapping file first (see https://docs.microsoft.com/en-us/sharepoint/dev/transform/modernize-userinterface-site-pages-urlmapping#custom-url-mapping) and see if the problem goes away?

antso77 commented 3 years ago

Hi @jansenbe, as I mentioned I tried with very simple mapping-file, only with one line: /sites/intranet/consulting,/sites/intra-consulting

jansenbe commented 3 years ago

Can you share the full log of a failing run. If you're concerned about confidentiality you can directly share to bjansen@microsoft.com. Problem is that I don't know which of the called functions is failing, hopefully a verbose report will provide some more context.

Does this happen on all pages or just some? If just on some it might make sense to investigate the page content.

Also, assume you're using the latest version?

antso77 commented 3 years ago

Full error from verbose log is in message above. Weird thing is that this started to happen in specific tenant with identical script when I've done migrations to other tenants. No issues before, so may this be somehow be related some error in tenant itself...

jansenbe commented 3 years ago

The stacktrace is not enough to understand what goes wrong, can you do a fiddler trace while transforming a page that fails and share that with me. Hope that provides more context on what goes wrong here.

If all pages fail then that's weird, if one page fails it might mean there's something specific on that page that results in this behavior

jansenbe commented 3 years ago

Any progress here or can I close this issue?

jansenbe commented 3 years ago

Closing per no feedback. If this is still a problem please open a new issue providing the requested fiddler trace.

jwiersem commented 3 years ago

@jansenbe @antso77 : I ran into this same error. It is in my case due to 'errors' in the URL mapping file. This line caused the exception:

/sectors/bf/ops/fieldcs/sdt/roadmap/documents/1.1%20kt%20map3_sw%20etdc).pptx,/sites/SDT-JWTEST16/Shared Documents/1.1 kt map3_sw etdc).pptx

Changing it to

/sectors/bf/ops/fieldcs/sdt/roadmap/documents/1.1%20kt%20map3_sw%20etdc%29.pptx,/sites/SDT-JWTEST16/Shared Documents/1.1 kt map3_sw etdc).pptx

fixed the issue. The difference is the escaping of the ) character. I am now doing a test with a new URL mapping file that has escaped page and file names in it to see if the error stays gone and the url mapping also works.