apache / incubator-kie-drools

Drools is a rule engine, DMN engine and complex event processing (CEP) engine for Java.
http://www.drools.org
Apache License 2.0
5.88k stars 2.5k forks source link

[new-parser] Empty query cannot be parsed #5891

Closed yurloc closed 6 months ago

yurloc commented 6 months ago

Parent issue

Failing tests

Rule code snippet

query "TestEmptyQuery"
    //conditions
end

query "TestSimpleQuery"
    d : Double()
end

Error output

14:29:07.729 [main] WARN  o.d.t.f.parser.SmokeParserTest.testParserSmoke:50 - 9 : query.drl
### parse : ANTLR4_PARSER_ENABLED = true
line 23:0 no viable alternative at input 'end\n\nquery'
14:29:07.832 [main] ERROR o.d.d.parser.antlr4.DRLParserWrapper.parse:77 - Exception while creating PackageDescr
java.lang.IllegalStateException: ctx.lhsPattern().size() == 0 : 
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsPatternBind(DRLVisitorImpl.java:538)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsPatternBind(DRLVisitorImpl.java:83)
    at org.drools.drl.parser.antlr4.DRLParser$LhsPatternBindContext.accept(DRLParser.java:2665)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:1047)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsUnary(DRLVisitorImpl.java:1034)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitLhsUnary(DRLVisitorImpl.java:83)
    at org.drools.drl.parser.antlr4.DRLParser$LhsUnaryContext.accept(DRLParser.java:2481)
    at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
    at org.drools.drl.parser.antlr4.DRLParserBaseVisitor.visitLhsUnarySingle(DRLParserBaseVisitor.java:201)
    at org.drools.drl.parser.antlr4.DRLParser$LhsUnarySingleContext.accept(DRLParser.java:2114)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:1047)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitQuerydef(DRLVisitorImpl.java:388)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitQuerydef(DRLVisitorImpl.java:83)
    at org.drools.drl.parser.antlr4.DRLParser$QuerydefContext.accept(DRLParser.java:1768)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:1047)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDrlStatementdef(DRLVisitorImpl.java:159)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDrlStatementdef(DRLVisitorImpl.java:83)
    at org.drools.drl.parser.antlr4.DRLParser$DrlStatementdefContext.accept(DRLParser.java:523)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitDescrChildren(DRLVisitorImpl.java:1047)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitCompilationUnit(DRLVisitorImpl.java:102)
    at org.drools.drl.parser.antlr4.DRLVisitorImpl.visitCompilationUnit(DRLVisitorImpl.java:83)
    at org.drools.drl.parser.antlr4.DRLParser$CompilationUnitContext.accept(DRLParser.java:435)
    at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visit(AbstractParseTreeVisitor.java:18)
    at org.drools.drl.parser.antlr4.DRLParserHelper.compilationUnitContext2PackageDescr(DRLParserHelper.java:91)
    at org.drools.drl.parser.antlr4.DRLParserWrapper.parse(DRLParserWrapper.java:75)
    at org.drools.drl.parser.antlr4.DRLParserWrapper.parse(DRLParserWrapper.java:55)
    at org.drools.drl.parser.DrlParser.lambda$parse$2(DrlParser.java:191)
    at org.drools.drl.parser.DrlParser.compileWithAntlr4Parser(DrlParser.java:204)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:191)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:179)
    at org.drools.drl.parser.DrlParser.parse(DrlParser.java:168)
    at org.drools.compiler.builder.impl.resources.DrlResourceHandler.process(DrlResourceHandler.java:55)
    at org.drools.compiler.builder.impl.PackageDescrBuilder.buildResource(PackageDescrBuilder.java:73)
    at org.drools.compiler.builder.impl.PackageDescrBuilder.build(PackageDescrBuilder.java:51)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.buildPackageDescr(CompositeKnowledgeBuilderImpl.java:173)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:116)
    at org.drools.compiler.builder.impl.CompositeKnowledgeBuilderImpl.build(CompositeKnowledgeBuilderImpl.java:109)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:274)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.buildKnowledgePackages(AbstractKieProject.java:220)
    at org.drools.compiler.kie.builder.impl.AbstractKieProject.verify(AbstractKieProject.java:84)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildKieProject(KieBuilderImpl.java:285)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:251)
    at org.drools.compiler.kie.builder.impl.KieBuilderImpl.buildAll(KieBuilderImpl.java:208)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:149)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:134)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromResources(KieUtil.java:121)
    at org.drools.testcoverage.functional.parser.SmokeParserTest.testParserSmoke(SmokeParserTest.java:52)
14:29:07.832 [main] ERROR o.d.c.k.b.impl.AbstractKieProject.buildKnowledgePackages:280 - Unable to build KieBaseModel:KieBaseModelName
[23,0]: no viable alternative at input 'end\n\nquery'
[0,0]: 
[0,0]: Parser returned a null Package

14:29:07.833 [main] ERROR o.d.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem:165 - KieBuilder errors: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=23, column=0
   text=no viable alternative at input 'end\n\nquery'], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=], Message [id=3, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=Parser returned a null Package]]

java.lang.AssertionError: [[Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=23, column=0
   text=no viable alternative at input 'end\n\nquery'], Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=], Message [id=3, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=Parser returned a null Package]]] 
Expecting empty but was: [Message [id=1, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=23, column=0
   text=no viable alternative at input 'end\n\nquery'],
    Message [id=2, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=],
    Message [id=3, kieBase=KieBaseModelName, level=ERROR, path=/var/home/jlocker/src/github.com/kiegroup/drools/drools-test-coverage/test-suite/src/test/resources/org/drools/testcoverage/functional/parser/smoke/query.drl, line=0, column=0
   text=Parser returned a null Package]]

    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:169)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromKieFileSystem(KieUtil.java:134)
    at org.drools.testcoverage.common.util.KieUtil.getKieBuilderFromResources(KieUtil.java:121)
    at org.drools.testcoverage.functional.parser.SmokeParserTest.testParserSmoke(SmokeParserTest.java:52)
yurloc commented 6 months ago

/take