I am a newbie in Ballerina, and I am trying to import some OpenAPI Connector (For example ballerinax / fraudlabspro.frauddetection) into my Ballerina project. However I keep facing the error as stated at below:
Compiling source
admin/test2: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-11-08 07:48:35,043] SEVERE {b7a.log.crash} - Cannot read field "flags" because "type.tsymbol" is null
java.lang.NullPointerException: Cannot read field "flags" because "type.tsymbol" is null
at org.wso2.ballerinalang.compiler.semantics.analyzer.CodeAnalyzer.visit(CodeAnalyzer.java:2709)
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 [test2:(1:1,1:1)] Compilation failed due to: Cannot read field "flags" because "type.tsymbol" is null
error: compilation contains errors
I have try dig up on the documentation and also GitHub, but no clue on what exact is this error about. Can someone help me on this?
Below is the code from my main.bal:
import ballerina/io;
import ballerinax/fraudlabspro.frauddetection as ff;
public function main() {
io:println("Hello, World!");
ff:Client baseClient = check new Client();
}
Can you please change the code as follows?
import ballerina/io;
import ballerinax/fraudlabspro.frauddetection as ff;
public function main() returns error? {
io:println("Hello, World!");
ff:Client baseClient = check new ff:Client();
}
You need to change the return type of the main
function to error?
because you use the check expression. When creating the ff:Client
object, you cannot omit ff:
prefix. The reason is explained in https://github.com/ballerina-platform/ballerina-lang/issues/41474#issuecomment-1780670293.