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

Sitecore Technical Workshops - Top FAQs customers asked on XM Cloud

Hi Readers, I want to talk to you about interesting things which we have been doing which is "Technical Workshops" for our customers, so here goes the scenarios. So, we have been doing multiple types of technical workshops.  1) Training customer and their Sitecore technical team on latest and the greatest technologies like XM Cloud & Another composable stack and try enabling them for new Sitecore tech stack. 2) Customers / Potential Customers have their agenda of existing pain points, and we take a workshop on topics around them with best practices etc. little on new technologies, so they also know the future. Basically, we prepare custom targeted presentations & demos for individual workshops, and make sure it helps them answer their questions and they get insights of where Sitecore eco systems has to offer from their versatile toolset and try to keep them up to date with it. So, Purpose of this blog is, because in all these customer & their technical team's

An error occurred while receiving the HTTP response to This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

You have noticed many times that everything was working fine and suddenly the below error starts coming and you find no way to work it out An error occurred while receiving the HTTP response to This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. The reason for this is the receiving size of WCF service is smaller then the data which is coming from service It was working before because it was small,So you will have to try to increase the receiving setting in your end point,Possible settings can be following maxStringContentLength="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxArrayLength="2147483647" That would definately help you!!!

Set up leprechaun code generation with Sitecore XM Cloud Starterkit

Hi Sitecorians, It has been amazing learning year so far and with the change in technology and shift of the focus on frontend frameworks and composable products, it has been market demand to keep learning and exploring new things. Reasons behind this blog Today's topic is something that was in my draft from April-May, and I always thought that there is already a good documentation out there for  Leprechaun  and a blog post is not needed, Until I realized that there was so many of us facing same kind of issues and same kind of problems and spending same amount of time, That is where I thought, if I could write something which can reduce that repetitive troubleshooting time, That would really help the community. 1)  In a project environment, if we get into some configuration issues, we resolve them, we make sure we are not blocked and continue, but if you think same issue, same step and same scenario will come to other people, so if we can draft it online, it will help other people 2