Sitecore: Target Item Could Not be Found


Today we experienced an issue, which we really struggled to troubleshoot. But in the end, the solution was really quite simple and should have been a bit more obvious! Adding it here in case someone else has a similar issue.

The Issue

The first issue was that users were reporting an error when trying to move items between folders. The item in question was fairly deep in the content tree and was a child item of one of our courses (which is initially created as part of an automated import process). When trying to copy the sub folder or items within, we recieved the error:

The target item could not be found

The error only happened when copying within the same branch of the content tree. A save to a folder near the root for example had no problem.

The second issue presented when, users tried to select a folder within the same are as a datasource for a component. In this situation, it fails to load the content and a log is added as below:

WARN '/sitecore/content/our/deep/path/to/course/Main Images' is not valid data source for 'master' database or user does not have permissions to access.

Our initial thoughts

Upon digging into the code, we could see that the operations above use the SOLR index to find the target items. Our intial thoughts were that somehow the master index must have been corrupted for that item. With that in mind, we kicked off a rebuild of the master index, hoping that would fix the issue.

After the rebuild, we could see that the item existed in the master index. However the problems were still happening…

The solution

After some further head scratching and trying a few more fixes, we reached out to sitecore support again.

To be fair to us, it took them a while to find the solution… After sending over a copy of our master DB and associated solution items. They were initially able to reproduce the error, but not find the root cause. Finally Yevhen from their team came back with the answer.

As I see the issue occurs as the name of the /sitecore/content/our/deep/path/to/course/ item in the Master database contains Carriage Return and Line Feed characters

Yevhen Povzlo

Seems obvious after being told the answer! But not at the time. Somehow these additional characters had been introduced into one of the source systems. That data had then been brought into sitecore via our automated import process. The characters were not visible when viewed in the content editor. Only it seems when querying the database directly.

So the simple fix, was to right click rename item. Typing in (not pasting!) the same name that appeared before. Upon saving, that then updated the index, which in turn resolved all our issues.

Leave a Reply

Your email address will not be published. Required fields are marked *