pnpcore
pnpcore copied to clipboard
Transforming pages in a subsite referring to images in site collection fails
Category
- [x] Bug
Describe the bug
Error:
Message: Test method PnP.Core.Transformation.SharePoint.Test.TransformationTests.SharePointTransformAsync threw exception: Microsoft.SharePoint.Client.ServerException: Server relative urls must start with SPWeb.ServerRelativeUrl Stack Trace: ClientRequest.ProcessResponseStream(Stream responseStream) ClientRequest.ProcessResponse() ClientRequest.ExecuteQueryToServerAsync(ChunkStringBuilder sb) ClientRequest.ExecuteQueryAsync() ClientRuntimeContext.ExecuteQueryAsync() ClientContext.ExecuteQueryAsync() ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext clientContext, Int32 retryCount, String userAgent) line 130 ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext clientContext, Int32 retryCount, String userAgent) line 93 SharePointFunctionsService.PersistImageFileContent(String sourceAssetRelativeUrl, ClientContext context, Int32 fileChunkSizeInMB) line 753 SharePointFunctionsService.RetrieveImageFileRelativePath(String sourceAssetRelativeUrl, ClientContext context) line 727 SharePointFunctionsService.ReturnCrossSiteRelativePath(String imageLink) line 702
Steps to reproduce
Scenario:
- Multi-lingual Intranet so English/French. English is a sub site called "EN"
- Pages that contain references to files in <SiteCollection>/PublishingImages library
Paths: https://capadevtest.sharepoint.com/sites/PnPSauce/en/Pages/Article-SPO-New-London-Flagship-Store.aspx https://capadevtest.sharepoint.com/sites/PnPSauce/PublishingImages/allspice-aromatic-chilli-33615.jpg?ctag=211010
Run transformation and the "PersistImageFileContent" tries to retrieve the file from the current Web. The function needs to cater for the current site collection as well.
Looking at the code, the caller RetrieveImageFileRelativePath prob needs to cater for this scenario.