Skip to content

when condition with struct pointer != nil causes panic #497

@LedoYang

Description

@LedoYang

Description
In a rule, if the when condition directly checks whether a struct pointer is != nil, the engine panics.

Example:

rule CheckModelManagerNotNil {
    when
        Engine.GetModelManager() != nil
    then
        Log("GetModelManager() != nil is true");
}

At runtime this produces an error:
time="2025-09-18T20:13:27+08:00" level=error msg="Failed testing condition for rule : CheckModelManagerNotNil. Got error error while evaluating rule CheckModelManagerNotNil, panic recovered" lib=grule-rule-engine package=engine

Steps to Reproduce:
1. Add an object Engine to the DataContext.
2. Engine.GetModelManager() returns a *ModelManager pointer (may be nil).
3. In the rule when section, write Engine.GetModelManager() != nil.
4. Run the rule engine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions