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}}