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
In the Application builder, all forms get passed through an external java program that runs the validation that CommCare mobile runs, and it'll tell you things like whether there's a circular dependency in your form logic, or if (as in the image) if you have a "select" question that has no options, etc.
Since this requires loading the form from couch (it's stored as an attachment) and then passing the form to an external process, it's actually quite time consuming, and since we want that to appear as an error message to the user, it's required on a bunch of page-loads, so we cache the result rather than running it each time.
The main place where validation_cache is used is in the function validate_form.
The Problem with Current Solution
Other than just being overly complicated, it appears that some part of it recently sprung a leak, as we're finding that some people's forms are showing up with a clean validation cache, but the form actually has problems.
The Proposed Solution
(This is me brainstorming now. I wanted to say md5 it and then use that as the cache key, but that requires having access to the form, and getting the form from the db is half the issue. Then I wanted to say, well then save the md5 of the form in the form json, inside FormSource.__set__, but I'm worried that then whatever the current issue is would continue to be an issue, since we haven't figured out what's causing the incorrect cache. It might work though, so perhaps still worth a try.)
The text was updated successfully, but these errors were encountered:
Background
In the Application builder, all forms get passed through an external java program that runs the validation that CommCare mobile runs, and it'll tell you things like whether there's a circular dependency in your form logic, or if (as in the image) if you have a "select" question that has no options, etc.
Since this requires loading the form from couch (it's stored as an attachment) and then passing the form to an external process, it's actually quite time consuming, and since we want that to appear as an error message to the user, it's required on a bunch of page-loads, so we cache the result rather than running it each time.
Overview of Current Solution
Forms have a property called
source
who's setter and getter are controlled by a "property descriptor": https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/app_manager/models.py#L330 (probably not necessary to understand deeply, but for reference: http://docs.python.org/2/howto/descriptor.html). The source XML itself is then saved as an attachment on the application instead of in the json.When
form.source
is set, thevalidation_cache
reset here https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/app_manager/models.py#L261. Thisvalidation_cache
is in turn controlled by another property descriptor (https://github.com/dimagi/commcare-hq/blob/master/corehq/apps/app_manager/models.py#L331) and essentially just saves that value to another couch doc. (I think we originally didn't want saving this validation to have be be done at the same time as saving the application, which is why it's in a separate doc.)The main place where
validation_cache
is used is in the functionvalidate_form
.The Problem with Current Solution
Other than just being overly complicated, it appears that some part of it recently sprung a leak, as we're finding that some people's forms are showing up with a clean validation cache, but the form actually has problems.
The Proposed Solution
(This is me brainstorming now. I wanted to say md5 it and then use that as the cache key, but that requires having access to the form, and getting the form from the db is half the issue. Then I wanted to say, well then save the md5 of the form in the form json, inside
FormSource.__set__
, but I'm worried that then whatever the current issue is would continue to be an issue, since we haven't figured out what's causing the incorrect cache. It might work though, so perhaps still worth a try.)The text was updated successfully, but these errors were encountered: