What happens
Passing a CEL optional to a function whose overload has a Python impl
kills the process (SIGSEGV, exit 139) before the function is called. The same
happens when the argument is a map holding an optional. A Python try cannot
catch it.
Reproduce
import sys
from cel_expr_python import cel
from cel_expr_python.ext import ext_optional
def show(x):
return "ok"
env = cel.NewEnv(
variables={"m": cel.Type.DYN},
extensions=[ext_optional.ExtOptional()],
functions=[cel.FunctionDecl("show", [
cel.Overload("show_any", cel.Type.STRING, [cel.Type("any")], impl=show),
])],
)
act = env.Activation({"m": {"a": 1}})
print(env.compile("show(m)").eval(act).value(), flush=True) # ok
print(env.compile(sys.argv[1]).eval(act).value(), flush=True)
| Expression |
Result |
show(m[?'a']) |
exit 139 |
show(optional.of(1)) |
exit 139 |
show({'k': optional.of(1)}) |
exit 139 |
show([optional.of(1)]) |
no crash: UNKNOWN: Unimplemented type: 17 |
Expected
An evaluation error, as the list case already gives, or the optional handed to
the function as a value.
Likely cause
CelValueToPyObject has no case for an optional and returns null with a
Python error set. PyCelFunctionAdapter::Invoke puts that null into the
argument tuple and calls the function without checking it.
Versions
cel-expr-python 0.1.3 from PyPI, and main at 45eefa7 built from source.
CPython 3.14.6, macOS arm64.
What happens
Passing a CEL optional to a function whose overload has a Python
implkills the process (SIGSEGV, exit 139) before the function is called. The same
happens when the argument is a map holding an optional. A Python
trycannotcatch it.
Reproduce
show(m[?'a'])show(optional.of(1))show({'k': optional.of(1)})show([optional.of(1)])UNKNOWN: Unimplemented type: 17Expected
An evaluation error, as the list case already gives, or the optional handed to
the function as a value.
Likely cause
CelValueToPyObjecthas no case for an optional and returns null with aPython error set.
PyCelFunctionAdapter::Invokeputs that null into theargument tuple and calls the function without checking it.
Versions
cel-expr-python 0.1.3 from PyPI, and
mainat45eefa7built from source.CPython 3.14.6, macOS arm64.