1

Recently we have been experiencing an issue with the Publishing Service while trying to publish anything. The following error appears in the SPS logs and the same message appears in Sitecore's publishing dialog.

2024-08-07 21:01:47.847 -05:00 [Error] There was an error performing the publish during stage: "" System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at Sitecore.Framework.Publishing.Data.ResourceItems.Model.ResourceItem.GetAllFields(Boolean includeShared, Boolean includeUnversioned, Boolean includeVersioned)+MoveNext() at Sitecore.Framework.Publishing.Data.ResourceItems.ResourceItemReadRepository.CollectVarianceMeta(ResourceItem item, ReadOnlyHashSet`1 languagesToLoad) at Sitecore.Framework.Publishing.Data.ResourceItems.ResourceItemReadRepository.ConstructItemNode(ResourceItem item, NodeQueryContext queryContext)

Example Error

1
  • While working on an upgrade to XM 10.4 I encountered this issue. Sitecore provided a hotfix to the Publishing Service which addressed the issue and negated the need for any other fixes. Commented Nov 8 at 18:13

1 Answer 1

3

The issue was related to items added to custom IAR files missing a language version.

Report

The following report can be used to help located items in IAR files that are missing the language version.

#https://www.maartenwillebrands.nl/2022/02/15/sitecore-removing-iar-items-from-the-database/

function Get-ModifiedItem {
    param(
        $databaseName,
        $filename
    )
    
    $resourceLoaderType = ([System.Type]::GetType("Sitecore.Data.DataProviders.ReadOnly.Protobuf.IResourceLoader, Sitecore.Data.ResourceItems.ProtobufNet"))
    $resourceLoader = [Sitecore.DependencyInjection.ServiceLocator]::ServiceProvider.GetService($resourceLoaderType)
    $paths = [System.Collections.Generic.List[String]]@()
    $paths.Add([Sitecore.MainUtil]::MapPath("/App_Data/items/$($databaseName)/$($filename)")) > $null
    $paths.Add([Sitecore.MainUtil]::MapPath("/sitecore modules/items/$($databaseName)/$($filename)")) > $null
    $defaultFieldValues = New-Object -TypeName 'System.Collections.Generic.Dictionary[[guid], [string]]'

    $database = [Sitecore.Configuration.Factory]::GetDatabase($databaseName)
    $connectionString = [System.Configuration.ConfigurationManager]::ConnectionStrings[$databaseName]
    $callContext = New-Object -TypeName "Sitecore.Data.DataProviders.CallContext, Sitecore.Kernel" -ArgumentList @($database.DataManager, $database.DataProviders.Count)
    $sqlDataProvider = New-Object -TypeName "Sitecore.Data.SqlServer.SqlServerDataProvider, Sitecore.Kernel" -ArgumentList @($connectionString)

    $itemDataSet = $resourceLoader.LoadFromFiles($paths, "dat", $defaultFieldValues)
    foreach($itemRecord in $itemDataSet.Definitions.Values) {
        <# Find items where a language version is missing #>
        $item = Get-Item -Path "$($databaseName):" -ID ([ID]::Parse($itemRecord.ID))
        if($item.Versions.GetVersions($true).Count -eq 0) {
            $item
        }
    }
}

$iarItemNames = Get-ChildItem -Path "$($AppPath)/sitecore modules/items/" -File -Filter *.dat -Recurse | Select-Object -ExpandProperty Name | Sort-Object

$options = [ordered]@{}
foreach($iarItemName in $iarItemNames) {
    $options[$iarItemName] = $iarItemName
}

$props = @{
    Parameters = @(
        @{Name="filename"; Title="Choose an option"; Tooltip="Additional details about the option"; Options=$options; }
    )
    Title = "Option Selector"
    Icon = "OfficeWhite/32x32/question.png"
    Description = "Choose an option."
    Width = 450
    Height = 300
    ShowHints = $true
}

$result = Read-Variable @props
if($result -eq "cancel"){
    exit
}

$databaseName = $filename.Split(".")[1]
Get-ModifiedItem -Database $databaseName -Filename $filename | Show-ListView -ViewName IARCleanup -ActionData @{"databaseName"=$databaseName;"filename"=$filename} -Property ID, Name, ItemPath, TemplateName, Database, Language, Version, @{Label="Revision";Expression={$_.__Revision}}

Sample Dialog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.