Console icon indicating copy to clipboard operation
Console copied to clipboard

Error while executing ItemExists(string path='//BUG')

Open alan-null opened this issue 1 year ago • 1 comments

Expected Behavior

No exceptions in logs

Actual Behavior

SPE Logs:

112336 08:34:42 INFO  Arbitrary script execution in ISE by user: 'sitecore\Admin'
ManagedPoolThread #8 08:34:42 ERROR Error while executing ItemExists(string path='//BUG')
Exception: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: Spe
   at Spe.Core.Provider.PsSitecoreItemProvider.GetItemForPath(String path)
   at Spe.Core.Provider.PsSitecoreItemProvider.ItemExists(String path)

Steps to Reproduce the Problem

  • open ISE
  • run Test-Path "//BUG"
  • see SPE logs

alan-null avatar Sep 19 '24 06:09 alan-null

These work as expected:

Test-Path -Path "//bug"
Get-Item -Path "master://bug"
Get-ChildItem -Path "//bug"

This threw an error:

Get-Item -Path "//bug"

michaellwest avatar Sep 19 '24 12:09 michaellwest

Confirmed as fixed. Splendid work, guys!

AdamNaj avatar Aug 11 '25 19:08 AdamNaj

Actually this was a bit more complex and needed some additional work as the fix provided caused the following piping crash (added what-if so that it's non destructive but demonstrates the problem)

Get-Item -Path "master:\content\" | Remove-Item -recurse -force -WhatIf

This e.g. caused scripts like "Purge Empty libraries" to not work.

AdamNaj avatar Oct 20 '25 14:10 AdamNaj