Fixing Invalid Lookup Source Issue in Sitecore

Hello Sitecore Folks

Recently while adding a datasource query in drop link i have faced a Error of Invalid lookup source in Sitecore . it was throwing error “End of string expected at position 50″ while using query : ” itempath/*[@@templatename=’Slide’]”.

I checked following things to troubleshoot the issue:

  1. If Datasource location specified in the query exists or not, and it exists.
  2. If Datasource template is defined in query exists or not , and it was there.
  3. If Datasource template is defined in query have same casing or not , and it was same.
  4. Following was the error coming at that field.

It turns out Sitecore doesn’t like hyphens “-” in query path, and few other which includes:

  1. If you query contains keyword “and
  2. If query contains keyword “or
  3. If query contains hyphen “

In my case when i checked the query and it contains keyword ““, which was basically failing and giving me error .

Solution

In order to fix this issue we can add escape character “#” before and after of the items that contains any of these keywords or hyphen “-“, so, for example:

Before : query:/sitecore/content/Horizontal/Modal Pop-Up Folder//*[@@templatename='Slide']

After :query:/sitecore/content/Horizontal/#Modal Pop-Up Folder#//*[@@templatename='Slide']

After making this change, the issue was fixed.

I hope this helps somebody.

Keep coding and keep pushing the boundaries of what’s possible with Sitecore development!

Happy learning 🙂

Leave a comment

I’m Garima

a Sitecore Developer with 8 years of overall experience, with the last 5 years focused deeply on Sitecore. I’m certified in Sitecore 9, Sitecore 10, Sitecore XM Cloud and Sitecore AI CMS for Developers, and bring hands-on expertise across Sitecore CDP, Content Hub, and personalization strategies — especially in headless architectures.

My tech stack includes strong experience with .NET, JavaScript, React, and Next.js, allowing me to build scalable and high-performing digital experiences.

🧠 Currently Learning:
I’m expanding my skill set in the areas of Generative AI, Google Cloud, and Machine Learning fundamentals — with a focus on how these technologies can power future-ready personalization and intelligent content delivery in composable DXP solutions.

🔗 Always eager to learn, adapt, and collaborate — building smarter digital solutions one sprint at a time.

Google Cloud Logo

My Google Cloud Learning Journey 🚀

I’m actively learning and earning certifications through Google Cloud Skills Boost — focused on Generative AI, Cloud, and more!

🔗 View My Cloud Skills Boost Profile

Archives

Recent Posts

Let’s connect

AI architecture caching CDP cli container containers Data Source debug developer devops docker docker desktop droplink droptree Error GIT github headless javascript leadership mentor mentorship multilist NEXT partial design path personalize powershell programming publishing Push REact runtime error services Sitecore Sitecore CDP sitecore community SUGKolkata technology treelist validation validation rules web-development xm-cloud