Skip to main content

XM Cloud - SXASTARTER Kit Setting up Leprechaun Exited with Code 1 Error

Hi Team,

We all have been using Code Generators like Glass Mapper for our applications, Today in this post we will see the error which comes when you run leprechaun against XM Cloud starter repository, Steps for setting up leprechaun which are universal step & there is nothing major and very well documented at Leprechaun, So we will not discuss those step, You can easily configure it from the leprehaun site.

Leprechaun is a universal, open API for code generation from Rainbow serialized or Sitecore serialized Sitecore templates. Leprechaun uses state-of-the-art Roslyn code generation technology instead of T4 templates for speedy generation that doesn't require Visual Studio.

(Taken from https://github.com/blipson89/Leprechaun)

Leprechaun is very well documented, so i will not talk much about it  But i will share some info where we were blocked for more than a week for which there was nothing available on the internet and those information i will share so you do not end up in the same issue

Scenario

We have used leprechaun for our couple of projects, and over there we had no major issues and it all worked fine for us (They were not on XM cloud Sxastarter repository, They were all on-prem XM), But recently we run into an issue for XM Cloud based code based, were we kept getting an exception from leprechaun "Leprechaun command exited with code 1"

I did so many changes to my configurations & also my leprechaun file to find out where could be the issue, but i was no where, it was always giving me this error, Steps i followed were

1) I changed my leprechaun to point to some wrong path of module.json in <configuration> node where we give path to module.json, there was no error and it all went and gave me proper messages back saying, there was no module found for which it can generate the code.

2) I also changed different code generation file, giving all of those at once and also tied giving them one by one by it was giving same error as "Exited with Code 1"

3) I tried switching to diagnosed modes in visual studio from tools->Options and in that Projects & solutions-> Build And Run and on right hand side, select "MSBuild project build output verbosity" to "Diagnostic" thinking that it might give something, but no luck, same error.

4) Uninstalled & install leprechaun again, but no luck

5) I compared with my on-prem projects with my XM Cloud and lepreachaun configurations were same and identical.

6) I tried it with simplest of the template thinking may be it could be templates causing issue, but same error.

7) Sometimes if you download the code generation files, they are generally blocked by default, so i also double checked that they are unblocked and have proper access, all good but same error.

With no clue, i reached out to leprechaun mentioning the behavior and thank you to ben lipson for getting on a call for this, and in our first call there was no clue, he was also surprised why there is no details of error and why its not working

Final Solution & Steps

ben lipson and i remained in touch for next couple of days to figure out  the issue, He update the nuget with some more logs via which we can figure out the issue, i updated my leprechaun with that and it worked, we got some error like following 


We were more interested in the error where it says "Endpoint dev was missing Authority (STS/Identity Server/AAD tenant URL) System.AggregateException"

This is where i felt it's something to do with the configuration either in leprechaun or on code, now ben lipson put more light on this where he mentioned about following code getting executed from leprechaun

The code in leprechaun at Leprechaun/ModuleConfigurationReader.cs at main · blipson89/Leprechaun (github.com)

That call is to Sitecore.DevEx.Configuration.FilesystemConfigurationManager, which resolves the sitecore.json file and calls Validate(). It's the Validate that's failing, indicating something is wrong with the Sitecore configuration.

So we looked into validate() method and that error was getting thrown from that code 
 

 


Now, because it was mentioning DEV end point and it uses sitecore.json file, I recollect that there is only one file where end points are mentioned and that is user.json file


So, i opened up user.json file and tried to observe it and with my surprise, authority which the error is mentioning was mentioned only in "XmCloud" ref and for all other environment like "dev", "local" there was no authority url mentioned, see below

 


 Now, this user.json file is created automatically and we do not change it manually, and it is not committed to source control too


But i just changed all the environment "dev", "local" and where ever the authority was not present and gave the value "https://auth.sitecorecloud.io/", Now i just tried to run the laprechaun again and i was so happy to see that it generated the model successfully and "exited with code 1" error was no more there and models got successfully created

 


 

Conclusion

I still have not figured out why my user.json do not have the authority url in all environment, but putting it to the above values works just fine

I reached out to sitecore too because,

 

The problem is that the command "dotnet sitecore cloud environment connect" does not require an authority to be passed, because the cloud plugin will assume that the authority is auth.sitecorecloud.io if it's blank.

However, Leprechaun doesn't use the cloud plugin, because it doesn't actually need to connect to Sitecore

Leprechaun isn't connecting to xm cloud. It's just using the devex API to find the yaml files. However, the devex api calls Validate, which might detected a problem with your user.json file, despite not actually needing to use it, and that is where i have reached out to sitecore

My other colleagues also facing the same issue and they also do not have authority in their user.json file, i am not sure why, All of they do not have it, so not sure what is the permanent solution to this, because we all are using standard sitecore xm cloud documentation located at https://doc.sitecore.com/xmc/en/developers/xm-cloud/walkthrough--setting-up-your-full-stack-xm-cloud-local-development-environment.html and the commands given there.

ben lipson will be changing the leprechaun code and releasing a new version which will output more error where it will mention the exact issue, which it is not outputting right now, so by looking it at it we can do the needed change, but the solution is to add "authority" url to all the environment if not present and run the leprechaun afterwards.

Note: This issue exists only in sxastarter repository because it contains multiple end points in user.json file.






Comments

Popular posts from this blog

Why SitecoreAI - Getting into the shoes of the customer how to select right CMS

Hi Team, Lately, I have been talking to lot of our customers / potential customers and having pre-sales demos where one question always comes is "Why Sitecore" ?  Now this question can be for any product which is out for sell. And as a technician I always get into product technical features, but at the same time as a pre-sales guy, it also makes me think, surely all competitive products have same features, so definitely answer to this is not in the technicalities.  If you step back and think, we are also a customer in our daily life and buy lot of things, what is that process we go through? When we buy, how can your customer decide if this is a right fit for you or not, why we select A over B? Is it price? is it service? Is it a brand? Is it about features? Is it about brand loyalty?  When it is a technical product, I am sure it cannot start with the technicalities of the product or selecting product itself, 100% not, I feel decision is always business strategy first and ...

Hell of sitecore aliases pipeline breaking the site with 500 error

Hello Friends, I belive this blog post is very important for everyone because, It has some very serious effect on working of your headless website, i will share my experience what we faced and how we resolved it Issue we started facing Our site started giving "Key cannot be null or empty" with YSOD like following  Side affect Because of this 500 error, Our site pages were showing 500 custom error page intermittently and our MAU (Monthly Active User) drop rate increased. Sitecore KB There is already Sitecore KB article talking about this error but the patch which is provided on this link is confusing as well as very huge and it could bring other issues along with it as that upgrade patch also has lot of other things too which i did not want to introduce in our stable CMS. Known Issues - Retrieving the child items of resource items is not thread-safe Observation Though the surfaced exception was looking similar and giving same error and behavior given on this article, We looked...

401.1 Unauthorized with windows authentication error code 0xc000006d

How many of you have faced this hosting issue when you do everything what it takes to run the site with windows authentication but still you are getting the same error again and again? If you think you also have faced the same issue and you tired of reading MSDN KBs for it and still have not found the issue (If KB has solved the issue, well and good, if not you can try this trick),Please Read below Typical scenario In typical hosting with IIS, i did every possible things like enabling windows authentication, changing it in web.config, configuring connection pool, authorization rules, it asks me for window authentication login and despite of entering correct credentials it always fails and keeps on asking for login, and when pressed cancel it gives 401.1 with 0xc000006d error code Solution (Which worked for me at-least after trying for almost 6-9 hrs) You need to change the Loop Back Check in registry so that it allows the host names which you are giving in url are allowed and au...