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] build failure on kie-dmn-validation #5879

Closed tkobayas closed 6 months ago

tkobayas commented 6 months ago

Parent issue

Failing rule

Notes

Rule code snippet

rule TYPEREF_NOT_FEEL_NOT_DEF_p1
when
  $o: Expression( !(this instanceof UnaryTests), typeRef != null, typeRef.prefix == null || getNamespaceURI( typeRef.prefix ) != getURIFEEL(), $typeRef : typeRef )
  (and (not ItemDefinition( name == $typeRef.getLocalPart() ) )
       (not (and Import($importName : name, $importedNS : namespace )
                 $importDef : Definitions( namespace == $importedNS ) from entry-point "DMNImports"
                 ItemDefinition( $typeRef.getLocalPart() == $importName + "." + name ) from $importDef.itemDefinition
            )
       )
  )

The problematic constraint is typeRef.prefix == null || getNamespaceURI( typeRef.prefix ) != getURIFEEL().

Error output

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:java (validation-bootstrap) on project kie-dmn-validation: An exception occured while executing the Java class. null: InvocationTargetException: Unable to create KieModule, Errors Existed: [Message [id=1, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=83, column=0
[ERROR]    text=no viable alternative at input 'getNamespaceURI'], Message [id=2, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=83, column=0
[ERROR]    text=mismatched input '!=' expecting {'not', 'in', 'matches', 'memberOf', 'contains', 'excludes', 'soundslike', 'str', 'after', 'before', 'coincides', 'during', 'includes', 'finishes', 'finishedby', 'meets', 'metby', 'overlaps', 'overlappedby', 'starts', 'startedby', '#', '!.', 'instanceof', '(', ')', '[', ',', '.', '>', '<', '~', '==', '<=', '>=', '!=', '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', IDENTIFIER}], Message [id=3, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=97, column=0
[ERROR]    text=no viable alternative at input 'getNamespaceURI'], Message [id=4, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=97, column=0
[ERROR]    text=mismatched input '!=' expecting {'not', 'in', 'matches', 'memberOf', 'contains', 'excludes', 'soundslike', 'str', 'after', 'before', 'coincides', 'during', 'includes', 'finishes', 'finishedby', 'meets', 'metby', 'overlaps', 'overlappedby', 'starts', 'startedby', '#', '!.', 'instanceof', '(', ')', '[', ',', '.', '>', '<', '~', '==', '<=', '>=', '!=', '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', IDENTIFIER}], Message [id=5, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=111, column=0
[ERROR]    text=no viable alternative at input 'getNamespaceURI'], Message [id=6, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=111, column=0
[ERROR]    text=mismatched input '!=' expecting {'not', 'in', 'matches', 'memberOf', 'contains', 'excludes', 'soundslike', 'str', 'after', 'before', 'coincides', 'during', 'includes', 'finishes', 'finishedby', 'meets', 'metby', 'overlaps', 'overlappedby', 'starts', 'startedby', '#', '!.', 'instanceof', '(', ')', '[', ',', '.', '>', '<', '~', '==', '<=', '>=', '!=', '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', IDENTIFIER}], Message [id=7, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=125, column=0
[ERROR]    text=no viable alternative at input 'getNamespaceURI'], Message [id=8, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=125, column=0
[ERROR]    text=mismatched input '!=' expecting {'not', 'in', 'matches', 'memberOf', 'contains', 'excludes', 'soundslike', 'str', 'after', 'before', 'coincides', 'during', 'includes', 'finishes', 'finishedby', 'meets', 'metby', 'overlaps', 'overlappedby', 'starts', 'startedby', '#', '!.', 'instanceof', '(', ')', '[', ',', '.', '>', '<', '~', '==', '<=', '>=', '!=', '&&', '||', '++', '--', '+', '-', '*', '/', '&', '|', '^', '%', IDENTIFIER}], Message [id=9, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=0, column=0
[ERROR]    text=], Message [id=10, kieBase=defaultKieBase, level=ERROR, path=org/kie/dmn/validation/DMNv1_1/dmn-validation-rules-typeref.drl, line=0, column=0
[ERROR]    text=Parser returned a null Package]]
tkobayas commented 6 months ago

/take

tkobayas commented 6 months ago

Well, it seems that we shouldn't rely on a semantic predicate in this case (orRistriction to operator_key).

https://github.com/antlr/antlr4/blob/master/doc/predicates.md#finding-visible-predicates

I posted a SO question : https://stackoverflow.com/questions/78417977/semantic-predicate-false-throws-noviablealtexception-in-adaptivepredict-then

tkobayas commented 6 months ago

Fixed by https://github.com/apache/incubator-kie-drools/pull/5899 https://github.com/apache/incubator-kie-drools/issues/5904 https://github.com/apache/incubator-kie-drools/pull/5905