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

One or more exceptions occurred while processing the subscribers to the 'item:creating' event

I was recently installing the packages from one of the QA environment to my local Sitecore instance, "Media library package" to be precise, And it started giving me this below error One or more exceptions occurred while processing the subscribers to the 'item:creating' event Looking at the sitecore logs, it gave me more info on the context and the actual inner exception was following Solution: 'Name' should consist only of letters, digits, dashes or underscore Now it was evident that some of my file names were violating the naming rule, I could see in the log just before exception from where the installer stopped creating items, and that file name had round braces "(" and ")" at the end of it, with my surprise I was able to create the item with those name in the content tree, but below was the solution for it, Solution I am using SC 9.0.1 and in that Go to Sitecore.Marketing.config file residing in "App_Config\Sitecore\Mar...

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...

Error in Sitecore 10.3 XM with CDs - Could not find configuration node: database/database[@id='master']

Hi Team, Recently we came across two distinct scenarios with same error message.  1) We started getting below error when we try to hit our layout service API endpoint. If we hit end point of CM, it was working fine and when we try to hit end point of CD it was giving this error, It was clear there is something in backend expecting master DB instead of WEB DB In first scenario my colleague  Jatin  also got same issue while setting up docker instance for 10.3, and my friend  Akshay Barve  and I had the same observation. 2) Second scenario I was having the same exception, It was another project on 10.3 XM with CD, It was one of the migration project so we were migrating from 10.2 to 10.3, Older site was not giving any error but new site the moment we hit, it was giving same exception in the log Issue in second scenario was in site grouping there was only site and both CM and CD URLs were given in host name and had WEB db as database, so basically there was no previ...