Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a TypeError instead of evaluation error #41

Open
danj opened this issue May 12, 2023 · 2 comments
Open

Getting a TypeError instead of evaluation error #41

danj opened this issue May 12, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed
Milestone

Comments

@danj
Copy link

danj commented May 12, 2023

Getting the wrong exception type when expression uses all
Expect to get an CELEvalError but instead of a TypeError

import celpy
from celpy import CELEvalError

env = celpy.Environment()

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    all_positive = "data.all(x, x>0)"
    breaks = {'data_': [1, 2, 3] }

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

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

Happy to try and fix with some guidance

@hardbyte
Copy link

hardbyte commented May 15, 2023

I'm curious why your context has data_ where your expression uses data - just to expose the issue right?

For reference, I see an evaluation error using:

    all_positive = "data.all(x, x > 0)"
    breaks = {'data': [1, 2, '3']}

But a type error using:

    all_positive = "true || data.all(x, x > 0)"
    breaks = {'data_': [1, 2, 3]}

@slott56 slott56 added the bug Something isn't working label May 21, 2024
@slott56
Copy link
Collaborator

slott56 commented May 21, 2024

I'm not sure what the baseline Golang CEL implementation does. If anyone has an example from the Go implementation, that would be helpful.

I am confident it does not expose a Python exception; it seems more likely that it returns a CEL error code.

@slott56 slott56 added the help wanted Extra attention is needed label May 21, 2024
@slott56 slott56 added this to the 0.3 release milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants