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
Hi,
I am playing with playground to scope what is achievable or not with CEL
and to spot what is valid CEL syntax or not.
Further Information
I try to implement an expression that return an object base on name
This example is for simplicity purpose only.
input: person: name: 'sam'
expression KO person.name == 'sam' ? { 'status': 'adult', 'age': 39} : { 'status': 'unknown', 'age': 0} is failing to compile
but as soon as I change "age" and "adult" properties to string
expression OKperson.name == 'sam' ? { "status": "adult", "age": "39"} : { "status": "adult", "age": "0"} it compiles and is evaluated
and even inconsistent object shape return is fine as long as all properties does have the same type
expression OK2 person.name == 'sam' ? { 'status': 'adult', 'age': '39'} : { 'status': 'unknown'}
sgendre
changed the title
Can't compile expression return structure with number but structure with string is ok
Can't compile expression that return objects with mixed properties types
Oct 18, 2024
Question
Hi,
I am playing with playground to scope what is achievable or not with CEL
and to spot what is valid CEL syntax or not.
Further Information
I try to implement an expression that return an object base on name
This example is for simplicity purpose only.
input:
person: name: 'sam'
expression KO
person.name == 'sam' ? { 'status': 'adult', 'age': 39} : { 'status': 'unknown', 'age': 0}
is failing to compilebut as soon as I change "age" and "adult" properties to string
expression OK
person.name == 'sam' ? { "status": "adult", "age": "39"} : { "status": "adult", "age": "0"}
it compiles and is evaluatedand even inconsistent object shape return is fine as long as all properties does have the same type
expression OK2
person.name == 'sam' ? { 'status': 'adult', 'age': '39'} : { 'status': 'unknown'}
Why is there such constraint?
You can play directly with
https://playcel.undistro.io/?content=H4sIAAAAAAAAA51TTUvDQBD9K2M8RKG2gicDRUQKflQrioiQy9hM08Xd2bAfrUX6351Ng6WHipgc8rIz897bmd2vbEo6K7LBAF5JT60hCBbCnOBqNIZHjava2cjVQcmSsrsGygMyKA7kcBrUgoTj%2FdJ7Mu96BY1dkqMKiBfKWTbEIXHTZ6OtI6msEian2shShflG1xpjGUafjSPvlcAxch2xJjgS%2FeN%2BctK6OYFXpwLBykbXWqNtzVyku6QXTy0xOkKQUMJeVQQz68R8EwNUGLAnGN4u78cgy7fPk4cUNxg6lsfEDPlT5LzdxQJ1xD3iWKNiH1qlrUBHNOr2n%2BqmVmuSzkmNnQkDmkaT74z5RjlMsbJ9pVjG0yjdrsHdpGRpnrfcZ5SpDYeQezQ5XMCXoIAh%2BryAHKuoQ94TUJP8n52vodjNiPzBdsnbnFNYd4KTu%2FT5u8xe7v8S%2FnjKz85%2FYc96WerwTeq1HOZDuJbxp%2BO5O4E9E%2B4ncxtPRckgT3JWbHyVLOTGViS86aqsvwHRXEQqMgMAAA%3D%3D
Screenshots
System Information
Additional Context
I dont know if the issue is specific to cel-playground or to the underlying used implementation
Thank for your time or for that online tool, it is so helpful to ramp-up 👍
The text was updated successfully, but these errors were encountered: