We used nested classes in LWC controller to have a single class with all the AuraEnabled parameters. That works in a no-namespace environment but stops working when we either package that or deploy to a scratch org with a namespace.

It throws the following internal error: An internal server error has occurred↵Error ID: 1249622784-2726276 (1294986922)

I created a repo with the code sample to illustrate the issue on Github

3 Answers 3


Turned out the problem is how AuraEnabled handles the namespaces. Currently, it's just impossible to use nested classes in namespaced Aura.

This is true for regular (non-LWC) Aura as well, but has a workaround.

I posted an idea to Salesforce to fix that.

I'm also talking to the TE team and partner support on this. They should get it to the platform team.

At this moment the only workaround for LWC I found is to not use nested classes ¯\(ツ)


Salesforce support reached out to me and provided a link to the known issue, which is marked as "No fix". They also advised me to promote the idea. So anyone interested in this - please vote for the idea.

Update 2

@Johann Furmann has found a workaround that does work, though looks a bit kludgy. See this answer. You can also see the implementation in my repo, branch fix

  • As an ISV with a namespaced environment it feels like they don't care about the likes of us too much
    – zaitsman
    Commented Jan 24, 2020 at 5:26
  • Well, at least the TE I was talking to promised to ping their Platform team. I'll keep in touch with her to see where it goes and will update this ticket with any information on this defect
    – nchursin
    Commented Jan 24, 2020 at 8:32

I found a funny workaround: Declare a @auraenabled variable at the top of the class of the type of the inner class. This way I could have as many levels of nested as I want.

public class OuterClass{

    public InnerWrapperClass wrapperVariable{get;set;} 

     public class InnerWrapperClass{
         String recorded;

I had to tackle this issue today and found another workaround for this. A little bit more elegant. Bonus at the end.

public static void callMe(Object request) {
    System.debug(request instanceof String); // true
    System.debug(JSON.deserialize((String)request, OuterClass.InnerClass.class)); // OuterClass:[ ... ]

The input must be stringified json (JSON.stringify).

Honestly, whole Salesforce platform is a joke and huge workaround.


Code below throws 500 internal server error. WTF

public static void callMe(String request) {
    System.debug(JSON.deserialize(request, OuterClass.InnerClass.class));
  • bonux - lol wat. Any detail of the error? I'll check the fix and will update the repo
    – nchursin
    Commented Mar 17, 2022 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .