Skip to content

“Stack is null or empty” error occurs when running SPE Publish-Item script #1382

@alan-null

Description

@alan-null

Copy of internal report:

Steps to reproduce:

  1. In XM Cloud, set the SITECORE_SPE_ELEVATION environment variable to Allow

  2. Navigate to Desktop > Powershell Console

  3. Run the Publish-Item command:

Publish-Item -Path master:\content\home -Target experienceedge

Actual results:

Following error occurs and publish failed:

Publish-Item : Stack is null or empty.
At line:1 char:1
+ Publish-Item -Path master:\content\home -Target experienceedge
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Publish-Item], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Spe.Commands.Data.PublishItemCommand

XMC logs
Image

Failing code - introduced to edge @01.07.2025

public virtual void Process(PublishContext context){
    // [...] logic
    if (context.Job.TryResolveOptions(new PublishLog(_log), out _, out var options))
    {
        // [...] logic
    }
    else
    {
        throw new InvalidOperationException("Failed to resolve publishing options for the job.");
    }
    // [...] logic
}

Expected results:
Publish succeeded.

Additional info:

I've been told that:

Since sitecore 6.4 the right way to initiate a publish is to use PublishManager:
https://archive.doc.sitecore.com/xp/en/SdnArchive/upload/sitecore6/64/content_api_cookbook_sc64_and_later-a4.pdf
section: 2.2 How to Publish

Also it looks like the current implementation of SpePublishManager allows parallel publish jobs (because it skips creation of standard publish jobs) which is incorrect and can cause issues on edge side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions