Pnp-sites-core: Modern Page Provisioning: Error when referencing header image from another site

Created on 22 Mar 2019  路  7Comments  路  Source: pnp/PnP-Sites-Core

Category

  • [x] Bug
  • [ ] Enhancement

Environment

  • [x] Office 365 / SharePoint Online
  • [ ] SharePoint 2016
  • [ ] SharePoint 2013

Version 3.7.1903.0

Expected or Desired Behavior

Modern pages can use a header image from another site. I observed one page that used the header image of another page in another site. While this might be questionable it should not make the provisioning fail.

This should provision:

<pnp:ClientSidePages>
    <pnp:ClientSidePage PageName="Home.aspx" PromoteAsNewsArticle="false" Overwrite="true" Layout="Home" EnableComments="false" Title="Homepage">
        <pnp:Header Type="Custom" ServerRelativeImageUrl="/sites/Demo/SiteAssets/SitePages/My-Home/external_header.jpg" TranslateX="51.0752688172043" TranslateY="23.2456140350877" />
    </pnp:ClientSidePage>
</pnp:ClientSidePages>

Note the ServerRelativeImageUrl of the Header. It is referencing an image in _another_ site's SiteAssets library.

Note that the above was generated using the extensibility handler to export pages. Using just core PnP the URL looks like this:

ServerRelativeImageUrl="/:i:/r/sites/Demo/SiteAssets/SitePages/My-Home/external_header.jpg"

Or maybe I used the other URL format in the repro. But it doesn't matter, nothing works. Both formats are showing the observed behavior.

Observed Behavior

Provisioning fails with error message:

PS C:\Users\heu> Apply-PnPProvisioningTemplate -Path "C:\Temp\template.xml" -Handlers PageContents,Pages
SharePointPnPPowerShellOnline\Apply-PnPProvisioningTemplate : Server relative urls must start with SPWeb.ServerRelativeUrl
At line:1 char:1
+ SharePointPnPPowerShellOnline\Apply-PnPProvisioningTemplate -Path "C: ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Apply-PnPProvisioningTemplate], ServerException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Provisioning.Site.ApplyProvisioningTemplate

Steps to Reproduce

  1. Configure a modern page to use a header image from another site's SiteAssets library
  2. Export this page using Get-PnPProvisioningTemplate -Out "template_homepage.xml" -Handlers PageContents,Pages
  3. Import the template using Apply-PnPProvisioningTemplate -Path "template_homepage.xml" -Handlers PageContents,Pages
  4. Error

(Looking at the suggestions by GitHub ticket #1836 might show related behavior.)

Most helpful comment

I'm adding a fix to not fail in this scenario but create a warning log entry for the April release. We'll most likely include options to export all client side pages in May release...at that point we'll have to also think about how to best handle the depending assets...which is related to this.

All 7 comments

I'm also seeing the same issue when a page references a banner image from another site. Is there any update on how we can work round this?

I agree that provision should not fail in this scenario but rather it needs to create the page without the header image being set. In order to fix this the only option I see is using an extensibility handler to export the clientside pages that after the export checks the header image urls, grabs the images and includes them in the template as part of the site assets library + updates the url in the client side page header to point to the new location of the header image.

@jansenbe Why not include this in the core framework?
(This topic might or might not be related to the discussion in #2124; note that the bug is also present for the exported (modern) home page, which is something the core engine currently supports without needing an extensibility handler).

I'm adding a fix to not fail in this scenario but create a warning log entry for the April release. We'll most likely include options to export all client side pages in May release...at that point we'll have to also think about how to best handle the depending assets...which is related to this.

A change was committed, will be part of the April drop which we'll release next week Friday

This outlook sounds very good. Thank you.

Agreed, this sounds really good. Will keep an eye for the May update.

Was this page helpful?
0 / 5 - 0 ratings