You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
List macros over a null receiver raise TypeError instead of a CEL error; size(null) returns 0 #201
importcelpyenv=celpy.Environment()
run=lambdae, a: env.program(env.compile(e)).evaluate(a)
run("x.exists(i, i == 1)", {"x": None}) # TypeError: 'NoneType' object is not iterablerun("false && x.exists(i, i == 1)", {"x": None}) # TypeError (expected: false)run("size(x)", {"x": None}) # 0 (expected: no such overload)
Per the CEL spec, applying a macro or size to null is an evaluation error ("no such overload"), and errors are absorbed by &&/|| (so false && <error> is false). Today the macro case escapes as a Python exception, so the whole expression fails even where a logical operator should settle it. #75 fixed the related case of a missing field (a CELEvalError receiver); an explicit null receiver still reaches the iteration in Evaluator.member_dot_arg.
A possible fix: in member_dot_arg, return a CELEvalError ("no such overload") when the receiver is not a list or map, as is already done when it is a CELEvalError; and have size raise the same for null.
Activity