Skip to content

Can't compile expression that return objects with mixed properties typesย #98

@sgendre

Description

@sgendre

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 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'}

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

image

System Information

  • OS: MacOS
  • OS Version: Latest

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 ๐Ÿ‘

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions