question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Item with ID cannot be deleted because it is not found in Sitecore 9.2+

See original GitHub issue

We are getting our logs spammed with messages like

WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found

I traced it back to here https://github.com/mikeedwards83/Glass.Mapper/blob/2bc3e9418bb9d3dd4fedd854e2e0e688dc5a86d1/Source/Glass.Mapper.Sc/RenderingParametersModelFactory.cs#L50

I added a log statement

Sitecore.Diagnostics.Log.Info("GLASS DELETE?", this); item.Delete(); //added for clean up

And confirmed logs:

17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={C100A1CF-6205-4F05-A636-0831DBADE1D0} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={88CC0F4C-EB54-4013-8228-83E558CF35AC} cannot be deleted because it is not found 17368 12:51:06 INFO GLASS DELETE? 17368 12:51:06 WARN Item with ID={B82C7AC0-46BD-4CD5-9D58-E4D9627646E6} cannot be deleted because it is not found 17368 12:51:07 INFO GLASS DELETE?

It looks like Sitecore in 9.2+ has changed that Delete() to log if the item is not found. Looks like in this case it is an in memory item only. Is it safe to just remove that item.Delete() line and let the GC do its thing? Happy to open a PR if so.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mikeedwards83commented, May 13, 2020

I have pushed a beta release with this fix, it also contains a flag in the config for backward compatibility. By default it will no longer delete the item, but setting the flag will restore the original logic.

https://github.com/mikeedwards83/Glass.Mapper/commit/74ff5e89e98724e5e258d2201bd9c033c842617d#diff-112f7122b703ee4f85649982cc0c249eR74

1reaction
swissworxcommented, May 12, 2020

@mikeedwards83 it looks fine to me, I quickly cracked the Sitecore dll open and I couldn’t find anything being allocated that is not cleaned up by the GC.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WARN Item with ID={97ADE186-643D-46A9-BAC5- ...
I think this is related to items that are still in your queues but no longer in the index - Sitecore tries to...
Read more >
Access an Item
If the item does not exist, or the context user does not have read access rights to the item, the Sitecore.Data.Database.GetItem method returns...
Read more >
error when I try to delete an item in Sitecore
1 Answer 1 · I've done as you instructed but for some reason now my code is not run at all... does "Copy...
Read more >
Sitecore Delete Published Items | Sitecore notes - Stelio Di Bello
In the case you want the item to be deleted and unpublished, you have to delete the item and have to publish the...
Read more >
Place an item in editing mode
Sitecore APIs that update items may throw exceptions if the item is not in editing mode. You can place an item in editing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found