cloud-custodian / cel-python

Pure Python implementation of the Common Expression Language
Apache License 2.0
99 stars 20 forks source link

Getting evaluation error for string type, int type comparison with None #48

Open hraj6056 opened 7 months ago

hraj6056 commented 7 months ago

Got an evaluation error ("found no matching overload for 'relation_eq' applied to '(<class 'celpy.celtypes.StringType'>, <class 'NoneType'>)'", <class 'TypeError'>, ("no such overload: StringType('temp') <class 'celpy.celtypes.StringType'> != None <class 'NoneType'>",))

all_positive = "record.fullname != null"
breaks = celpy.json_to_cel({'record': {'fullname': 'temp', 'overdraftProtection': False} })

ast = env.compile(all_positive)
prgm = env.program(ast)

try:
    result =prgm.evaluate(breaks)
    print(result)
except CELEvalError as ex:
    print('Got an evaluation error', ex)
except TypeError as ex:
    print('Got a type error')

Is there any hack or something to succesfully evaluate this as it is working in this CELPlayground which is built in go.

kapilt commented 6 months ago

I think just needs us to add the additional type comparisons against None, I don't have bandwidth on the moment for this, but pull requests welcome.