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

fix: catch ValueError and ZeroDivision errors on early jexl evaluation #2027

Merged

Conversation

StephanH90
Copy link
Contributor

@StephanH90 StephanH90 commented Jul 4, 2023

Description

Currently, starting a new case fails if any of the JEXL evaluations in a form return a ZeroDivisionError in the signal layer.

Fix

Add ValueError and ZeroDivisionError to catch block around JEXL evaluation in signal layer.

More detailed description

We evaluate JEXL expressions greedily in the signal layer, but do so without raising:

value = jexl.evaluate(field.question.calc_expression, raise_on_error=False)

However, in the jexl.update function we only catch TypeError:

def evaluate(self, expr, raise_on_error=True):

This is also not consistent with the catch block here, where we catch TypeError, ValueError and ZeroDivisionError:

def _handle_error(func, subject, *args):

This fix is time-critical as it is currently not possible to start a certain form which uses many calculated fields.

Copy link
Contributor

@winged winged left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - but please no mention of customers (or their problems) in public spaces

@StephanH90 StephanH90 merged commit f19ebbb into projectcaluma:main Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants