Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Set-PnPPage translation a full width section page #4382

Open
2 of 6 tasks
TycoMoon opened this issue Oct 4, 2024 · 4 comments
Open
2 of 6 tasks

[BUG] Set-PnPPage translation a full width section page #4382

TycoMoon opened this issue Oct 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@TycoMoon
Copy link

TycoMoon commented Oct 4, 2024

Reporting an Issue or Missing Feature

Issue: Set-PnPPage cmdlet error when trying to translate a page with a full width section.

Expected behavior

I expect the Set-PnPPage cmdlet to successfully copy the translated page without errors.

Actual behavior

When running the command:

Set-PnPPage -Identity "Yo.aspx" -Translate -TranslationLanguageCodes 1036 -LayoutType "Article"

I receive the following error:

2024-10-04T14:23:15Z   [Error]   ERROR: You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed

Exception             : 
    Type        : System.Management.Automation.PSInvalidOperationException
    ErrorRecord : 
        Exception             : 
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvalidOperation
    TargetSite  : 
        Name          : ProcessRecord
        DeclaringType : [PnP.PowerShell.Commands.Base.PnPConnectedCmdlet]
        MemberType    : Method
        Module        : PnP.PowerShell.dll
    Message     : You cannot host text controls inside a one column full width section, only an image web part or hero web part are allowed
    Source      : PnP.PowerShell
    HResult     : -2146233079
    StackTrace  : 
   at PnP.PowerShell.Commands.Base.PnPConnectedCmdlet.ProcessRecord() in D:\a\powershell\powershell\src\Commands\Base\PnPConnectedCmdlet.cs:line 101
   at PnP.PowerShell.Commands.PnPSharePointCmdlet.ProcessRecord() in D:\a\powershell\powershell\src\Commands\Base\PnPSharePointCmdlet.cs:line 126
   at System.Management.Automation.Cmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : InvalidOperation: (:) [Set-PnPPage], PSInvalidOperationException
FullyQualifiedErrorId : InvalidOperation,PnP.PowerShell.Commands.Pages.SetPage
InvocationInfo        : 
    MyCommand        : Set-PnPPage
    ScriptLineNumber : 107
    OffsetInLine     : 5
    HistoryId        : 1
    ScriptName       : C:\home\site\wwwroot\translation\run.ps1
    Line             :     Set-PnPPage -Identity $pageName -Translate -TranslationLanguageCodes $lcid -LayoutType $pageSource.LayoutType

    Statement        : Set-PnPPage -Identity $pageName -Translate -TranslationLanguageCodes $lcid -LayoutType $pageSource.LayoutType
    PositionMessage  : At C:\home\site\wwwroot\translation\run.ps1:107 char:5
                       +     Set-PnPPage -Identity $pageName -Translate -TranslationLanguageCo …
                       +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\home\site\wwwroot\translation
    PSCommandPath    : C:\home\site\wwwroot\translation\run.ps1
    InvocationName   : Set-PnPPage
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\translation\run.ps1: line 107

Despite using only an image in the full width section.

Steps to reproduce behavior

  1. Create a page in a site with translation enabled in any language.
  2. Create a full width section and add an image WebPart in it.
  3. Attempt to translate the page using the following command:
Set-PnPPage -Identity "yourpage.aspx" -Translate -TranslationLanguageCodes 1036 -LayoutType "Article"

Error Message


What is the version of the Cmdlet module you are running?

"2.99.2-nightly" (also tried "1.12.0")

Which operating system/environment are you running PnP PowerShell on?

  • Windows
  • Linux
  • MacOS
  • Azure Cloud Shell
  • Azure Functions
  • Other : please specify
@TycoMoon TycoMoon added the bug Something isn't working label Oct 4, 2024
@jackpoz
Copy link
Contributor

jackpoz commented Oct 4, 2024

This is the stacktrace:

at PnP.Core.Model.SharePoint.PageWebPart.ToHtml(Single controlIndex)
at PnP.Core.Model.SharePoint.CanvasColumn.ToHtml()
at PnP.Core.Model.SharePoint.CanvasSection.ToHtml()
at PnP.Core.Model.SharePoint.Page.ToHtml()
at PnP.Core.Model.SharePoint.Page.SaveAsync(String pageName)
at PnP.Core.Model.SharePoint.Page.Save(String pageName)
at PnP.PowerShell.Commands.Pages.SetPage.ExecuteCmdlet() in PnP\powershell\src\Commands\Pages\SetPage.cs:line 152

So the issue is more related to PnP.Core than PnP.PowerShell by the look of it.

@jackpoz
Copy link
Contributor

jackpoz commented Oct 4, 2024

It seems that image webpart is missing the isFullWidth property somehow. See below how properties.TryGetProperty("isFullWidth", ...) returned false:
image

@TycoMoon
Copy link
Author

TycoMoon commented Oct 7, 2024

Thank you ! It would be great if we could fix/disable this condition. I'm having trouble dodging this bug on my end. 😄

@TycoMoon
Copy link
Author

Hello,
The issue in pnpcore seems to be resolved, but the bug remains. I tried the same process with the latest nightly release "2.99.51-nightly".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants