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

[Bug]: Compiler throws NPE when referring to the openapi generated client #41557

Closed
niveathika opened this issue Oct 23, 2023 · 3 comments
Closed
Assignees
Labels
Reason/Other None of the other reasons. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation

Comments

@niveathika
Copy link
Contributor

Description

$subject

gmail:Client gmailClient = check new Client(
        config = {
            auth: {
                refreshToken: refreshToken,
                clientId: clientId,
                clientSecret: clientSecret
            }
        }
    );
Compiling source
        niveathika/process_mails:0.1.0
ballerina: Oh no, something really went wrong. Bad. Sad.

We appreciate it if you can report the code that broke Ballerina in
https://github.com/ballerina-platform/ballerina-lang/issues with the
log you get below and your sample code.

We thank you for helping make us better.

[2023-10-23 11:43:02,854] SEVERE {b7a.log.crash} - Cannot read field "tag" because "referredType" is null 
java.lang.NullPointerException: Cannot read field "tag" because "referredType" is null
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:2232)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.accept(BLangRecordLiteral.java:81)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeExpr(CodeAnalyzer.java:3514)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:3190)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.expressions.BLangNamedArgsExpression.accept(BLangNamedArgsExpression.java:75)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeExpr(CodeAnalyzer.java:3514)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeExprs(CodeAnalyzer.java:3585)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:2706)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.expressions.BLangTypeInit.accept(BLangTypeInit.java:70)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeExpr(CodeAnalyzer.java:3514)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:3196)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.expressions.BLangCheckedExpr.accept(BLangCheckedExpr.java:70)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeExpr(CodeAnalyzer.java:3514)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:1717)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.BLangSimpleVariable.accept(BLangSimpleVariable.java:59)
        at org.wso2.ballerinalang.compiler.tree.SimpleBLangNodeAnalyzer.visitNode(SimpleBLangNodeAnalyzer.java:215)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeNode(CodeAnalyzer.java:349)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:1834)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.statements.BLangSimpleVariableDef.accept(BLangSimpleVariableDef.java:55)
        at org.wso2.ballerinalang.compiler.tree.SimpleBLangNodeAnalyzer.visitNode(SimpleBLangNodeAnalyzer.java:215)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeNode(CodeAnalyzer.java:349)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:538)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.BLangBlockFunctionBody.accept(BLangBlockFunctionBody.java:65)
        at org.wso2.ballerinalang.compiler.tree.SimpleBLangNodeAnalyzer.visitNode(SimpleBLangNodeAnalyzer.java:215)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeNode(CodeAnalyzer.java:349)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visitFunction(CodeAnalyzer.java:513)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:456)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.BLangFunction.accept(BLangFunction.java:81)
        at org.wso2.ballerinalang.compiler.tree.SimpleBLangNodeAnalyzer.visitNode(SimpleBLangNodeAnalyzer.java:215)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeNode(CodeAnalyzer.java:349)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyzeTopLevelNodes(CodeAnalyzer.java:338)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:326)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:280)
        at org.wso2.ballerinalang.compiler.tree.BLangPackage.accept(BLangPackage.java:172)
        at org.wso2.ballerinalang.compiler.tree.SimpleBLangNodeAnalyzer.visitNode(SimpleBLangNodeAnalyzer.java:215)
        at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.analyze(CodeAnalyzer.java:314)
        at io.ballerina.projects.internal.CompilerPhaseRunner.codeAnalyze(CompilerPhaseRunner.java:196)
        at io.ballerina.projects.internal.CompilerPhaseRunner.performTypeCheckPhases(CompilerPhaseRunner.java:119)
        at io.ballerina.projects.ModuleContext.compileInternal(ModuleContext.java:435)
        at io.ballerina.projects.ModuleCompilationState$1.compile(ModuleCompilationState.java:45)
        at io.ballerina.projects.ModuleContext.compile(ModuleContext.java:383)
        at io.ballerina.projects.PackageCompilation.compileModulesInternal(PackageCompilation.java:208)
        at io.ballerina.projects.PackageCompilation.compileModules(PackageCompilation.java:192)
        at io.ballerina.projects.PackageCompilation.compile(PackageCompilation.java:99)
        at io.ballerina.projects.PackageCompilation.from(PackageCompilation.java:94)
        at io.ballerina.projects.PackageContext.getPackageCompilation(PackageContext.java:242)
        at io.ballerina.projects.Package.getCompilation(Package.java:150)
        at io.ballerina.projects.Package.runCodeGeneratorPlugins(Package.java:319)
        at io.ballerina.cli.task.CompileTask.execute(CompileTask.java:142)
        at io.ballerina.cli.TaskExecutor.executeTasks(TaskExecutor.java:40)
        at io.ballerina.cli.cmd.RunCommand.execute(RunCommand.java:223)
        at java.base/java.util.Optional.ifPresent(Optional.java:178)
        at io.ballerina.cli.launcher.Main.main(Main.java:58)
 
ERROR [process_mails:(1:1,1:1)] Compilation failed due to: Cannot read field "tag" because "referredType" is null
error: compilation contains errors

Steps to Reproduce

No response

Affected Version(s)

2201.8.1

OS, DB, other environment details and versions

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels Oct 23, 2023
@MaryamZi
Copy link
Member

The crash should be fixed anyway. But, is it intentionally Client on the RHS and if so is Client defined in the same module or should it have been gmail:Client (or be omitted)?

@MaryamZi MaryamZi added Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. and removed needTriage The issue has to be inspected and labeled manually labels Oct 23, 2023
@niveathika
Copy link
Contributor Author

@MaryamZi My bad. It was supposed to be gmail:Client. There was no additional client defined in the module. This should have resulted in error.

@MaryamZi MaryamZi added the Reason/Other None of the other reasons. label Oct 26, 2023
@MaryamZi
Copy link
Member

Duplicate of #41474.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reason/Other None of the other reasons. Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug userCategory/Compilation
Projects
None yet
Development

No branches or pull requests

4 participants