Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prettier-plugin-apex throwing Internal error in version 2.2.2 #1733

Open
2 tasks done
studcroc opened this issue Nov 26, 2024 · 4 comments
Open
2 tasks done

prettier-plugin-apex throwing Internal error in version 2.2.2 #1733

studcroc opened this issue Nov 26, 2024 · 4 comments

Comments

@studcroc
Copy link

Self-Troubleshooting Checklist

  • Are you running Prettier Apex >= 2.0.0? If Yes, have you gone through the Upgrade Guide?
  • Are you running VSCode and recently upgraded Prettier or Prettier Apex? If Yes, have you restarted VSCode after the upgrade?

Describe your issue

I'm running the prettier-plugin-apex in CI CD pipeline. Till version 2.1.4, everything is just fine but now in latest version 2.2.2. I'm getting some Internal error thrown by the plugin.

Though the plugin still scans and does it's job it seems but it keeps throwing error along.

I'm pasting the some portion of error log here due to length limitation for better understanding. Please find the complete log in the attached text file.

prettier_plugin_apex_errorlog.txt

prettier --check "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}"
Checking formatting...
[warn] .gitlab-ci.yml
[error] force-app/main/default/classes/sf/dummy_directory/DummyClass.cls: Error: {"apex.jorje.semantic.compiler.parser.ParserOutput": {"internalErrors": [],"parseErrors": [],"unit": {"@class": "apex.jorje.data.ast.CompilationUnit$ClassDeclUnit","body": {"@class": "apex.jorje.data.ast.ClassDecl","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 16,"endIndex": 23330,"line": 2,"column": 9},"modifiers": [{"@class": "apex.jorje.data.ast.Modifier$Annotation","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 0,"endIndex": 7,"line": 1,"column": 1},"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 1,"endIndex": 7,"line": 1,"column": 2},"value": "isTest"},"parameters": []},{"@class": "apex.jorje.data.ast.Modifier$PrivateModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 8,"endIndex": 15,"line": 2,"column": 1}}],"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 22,"endIndex": 42,"line": 2,"column": 15},"value": "KnowledgeArticleTest"},"typeArguments": {},"members": [{"@class": "apex.jorje.data.ast.BlockMember$MethodMember","methodDecl": {"@class": "apex.jorje.data.ast.MethodDecl","modifiers": [{"@class": "apex.jorje.data.ast.Modifier$Annotation","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 47,"endIndex": 57,"line": 3,"column": 3},"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 48,"endIndex": 57,"line": 3,"column": 4},"value": "TestSetup"},"parameters": []},{"@class": "apex.jorje.data.ast.Modifier$StaticModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 60,"endIndex": 66,"line": 4,"column": 3}}],"type": {"value": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 67,"endIndex": 71,"line": 4,"column": 10},"value": "void"}],"typeArguments": []}},"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 72,"endIndex": 77,"line": 4,"column": 15},"value": "setup"},"parameters": [],"stmnt": {"value": {"@class": "apex.jorje.data.ast.Stmnt$BlockStmnt","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 80,"endIndex": 111,"line": 4,"column": 23},"stmnts": [{"@class": "apex.jorje.data.ast.Stmnt$VariableDeclStmnt","variableDecls": {"@class": "apex.jorje.data.ast.VariableDecls","modifiers": [],"type": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": [86](https://gitlab.industrysoftware.automation.siemens.com/slm-sf/physical-structure/-/jobs/40763597#L86),"endIndex": 92,"line": 5,"column": 5},"value": "String"}],"typeArguments": []},"decls": [{"@class": "apex.jorje.data.ast.VariableDecl","name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 93,"endIndex": 97,"line": 5,"column": 12},"value": "name"},"assignment": {"value": {"@class": "apex.jorje.data.ast.Expr$LiteralExpr","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 100,"endIndex": 106,"line": 5,"column": 19},"type": {"@class": "apex.jorje.data.ast.LiteralType","$": "STRING"},"literal": {"@class": "string","$": "abcd"}}}}]}}]}}}},{"@class": "apex.jorje.data.ast.BlockMember$InnerClassMember","body": {"@class": "apex.jorje.data.ast.ClassDecl","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 123,"endIndex": 20203,"line": 8,"column": 11},"modifiers": [{"@class": "apex.jorje.data.ast.Modifier$PrivateModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 115,"endIndex": 122,"line": 8,"column": 3}}],"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 129,"endIndex": 152,"line": 8,"column": 17},"value": "MockHttpArticleResponse"},"typeArguments": {},"members": [{"@class": "apex.jorje.data.ast.BlockMember$MethodMember","methodDecl": {"@class": "apex.jorje.data.ast.MethodDecl","modifiers": [{"@class": "apex.jorje.data.ast.Modifier$PublicModifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 186,"endIndex": 192,"line": 9,"column": 5}}],"type": {"value": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 193,"endIndex": 205,"line": 9,"column": 12},"value": "HttpResponse"}],"typeArguments": []}},"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 206,"endIndex": 213,"line": 9,"column": 25},"value": "respond"},"parameters": [{"@class": "apex.jorje.data.ast.ParameterRefs$EmptyModifierParameterRef","typeRef": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 214,"endIndex": 225,"line": 9,"column": 33},"value": "HttpRequest"}],"typeArguments": []},"name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 226,"endIndex": 233,"line": 9,"column": 45},"value": "request"}}],"stmnt": {"value": {"@class": "apex.jorje.data.ast.Stmnt$BlockStmnt","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 235,"endIndex": 20199,"line": 9,"column": 54},"stmnts": [{"@class": "apex.jorje.data.ast.Stmnt$VariableDeclStmnt","variableDecls": {"@class": "apex.jorje.data.ast.VariableDecls","modifiers": [],"type": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 243,"endIndex": 255,"line": 10,"column": 7},"value": "HttpResponse"}],"typeArguments": []},"decls": [{"@class": "apex.jorje.data.ast.VariableDecl","name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 256,"endIndex": 264,"line": 10,"column": 20},"value": "response"},"assignment": {"value": {"@class": "apex.jorje.data.ast.Expr$NewExpr","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 267,"endIndex": 270,"line": 10,"column": 31},"creator": {"@class": "apex.jorje.data.ast.NewObject$NewStandard","type": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 271,"endIndex": 283,"line": 10,"column": 35},"value": "HttpResponse"}],"typeArguments": []},"inputParameters": []}}}}]}},{"@class": "apex.jorje.data.ast.Stmnt$VariableDeclStmnt","variableDecls": {"@class": "apex.jorje.data.ast.VariableDecls","modifiers": [],"type": {"@class": "apex.jorje.data.ast.TypeRefs$ClassTypeRef","names": [{"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 293,"endIndex": 299,"line": 11,"column": 7},"value": "String"}],"typeArguments": []},"decls": [{"@class": "apex.jorje.data.ast.VariableDecl","name": {"@class": "apex.jorje.data.Identifiers$LocationIdentifier","loc": {"@class": "apex.jorje.data.IndexLocation","startIndex": 300,"endIndex": 310,"line": 11,"column": 14},"value": "articleRes"},"assignment": {"value": {"@class": "apex.jorje.data.ast.Expr$BinaryExpr","left": {"@class": "apex.jorje.data.ast.Expr$BinaryExpr","left": {"@class": "apex.jorje.data.ast.Expr$BinaryExpr","left": {"@class": 

Prettier options (if any)

No response

System Info

System:
    OS: Linux 4.18 Alpine Linux
    CPU: (16) x64 AMD EPYC 7543 32-Core Processor
    Memory: 108.98 GB / 125.39 GB
    Container: Yes
    Shell: Unknown - /bin/sh
  Binaries:
    Node: 20.15.1 - /usr/bin/node
    npm: 10.9.1 - /usr/bin/npm
  Languages:
    Bash: 5.2.26 - /bin/bash
  npmPackages:
    @prettier-apex/apex-ast-serializer-linux-x64:  2.2.2 
    @prettier/plugin-xml: ^2.0.1 => 2.2.0 
    prettier: ^3.0.0 => 3.3.3 
    prettier-plugin-apex: 2.2.2 => 2.2.2
@dangmai
Copy link
Owner

dangmai commented Nov 26, 2024

Hi there, thank you for reporting this issue. This is definitely very interesting, and I don't have a clear idea why it's happening just yet. Does this happen to only one file in your repository, or does it happen to every file?
If it's just one file, is it possible for you to send me that file so I can check the content?
Also, do you run into this issue locally or just in the CI/CD context?

On a technical note, reading the stack trace, it looks like the program is running into a stack overflow during the serialization process. I'm very curious how that could've happened.

@dangmai
Copy link
Owner

dangmai commented Nov 26, 2024

One thing to try is to set the apexStandaloneParser config to none temporarily (guide here) to see if the root cause is from the native binary (introduced as the default parser in 2.2.0) or from some other causes.

@studcroc
Copy link
Author

One thing to try is to set the apexStandaloneParser config to none temporarily (guide here) to see if the root cause is from the native binary (introduced as the default parser in 2.2.0) or from some other causes.

This worked. Thanks!

@studcroc
Copy link
Author

studcroc commented Nov 27, 2024

Hi there, thank you for reporting this issue. This is definitely very interesting, and I don't have a clear idea why it's happening just yet. Does this happen to only one file in your repository, or does it happen to every file? If it's just one file, is it possible for you to send me that file so I can check the content? Also, do you run into this issue locally or just in the CI/CD context?

On a technical note, reading the stack trace, it looks like the program is running into a stack overflow during the serialization process. I'm very curious how that could've happened.

It's happening to certain number of files but not all. I cannot share the exact file here but I'll try to get a similar class file where I can reproduce the issue. That should help you understand the problem better.

And yes, it's just happening in the context of CI/CD, working just fine on my local machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants