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

Catch all errors when recomputing values in a field-list and show a helpful dialog #4750

Closed
lognaturel opened this issue Jul 29, 2021 · 3 comments · Fixed by #4758
Closed
Assignees

Comments

@lognaturel
Copy link
Member

This form has a select minimal with a value that gets used in a calculate for another select that was previously filtered to have no choices. It causes this crash. Because the second select's choices have never been rendered, choices are not attached to the selection.

Somewhat related, this crash can be reproduced by having a calculate on a select that produces a value not related to the choices. e.g. I put "foobar" in the calculate for a select that did not include "foobar" in its choices.

Also related to #4170.

People think they can use calculates as dynamic defaults. That will not work and they should not do that. In a way, it's not so bad that it crashes so catastrophically because at least they're not getting bad values which they would if the calculate succeeded. This can be fixed by adding a trigger. For example, in the sample form at top, add ${select} in the trigger column. That is how dynamic defaults are supposed to be expressed.

Could we perhaps catch all of these and show a better error message suggesting there might be a misuse of calculates?

@grzesiek2010
Copy link
Member

grzesiek2010 commented Jul 29, 2021

It would be great to catch the exception and throw FormDesignException but it's not easy to identify that this is it...
Generally updating field-lit groups is a source of many possible issues so we could maybe just wrap everything in try-catch and display a dialog that something went wrong and it might be a form design issue.

@lognaturel
Copy link
Member Author

lognaturel commented Jul 29, 2021

wrap everything in try-catch and display a dialog that something went wrong and it might be a form design issue.

That sounds good to me. I've also filed a pyxform issue at XLSForm/pyxform#546 The Collect message could be something like Failure trying to update values. This is generally because of incorrect usage of calculations in the form design. + \n\nR.id.report_to_project_lead

Then the form should probably just close? It seems there's nothing of value that can be done with a form that has this kind of issue.

@lognaturel lognaturel changed the title Crash when using minimal select that updates another select with a calculate Catch all errors when recomputing values in a field-list and show a helpful dialog Jul 29, 2021
@grzesiek2010 grzesiek2010 self-assigned this Jul 29, 2021
@seadowg seadowg added this to the v2021.2 milestone Jul 30, 2021
@lognaturel
Copy link
Member Author

lognaturel commented Oct 4, 2021

The two first cases with calculates and selects turn out to be the same as opening a record for edit. That is, there has to be an attempt to bind the selected answer(s) to the available choices or we can’t open a record for edit.

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 a pull request may close this issue.

3 participants