getodk / validate

ODK Validate is a Java application for confirming that a form is valid and compliant with the ODK XForms specification. Contribute and make the world a better place! ✨🔍✨
https://docs.getodk.org/validate/
Other
9 stars 26 forks source link

Indexed repeat with incorrect number of parameters #60

Closed joeflack4 closed 5 years ago

joeflack4 commented 5 years ago

Problem description

An issue in which indexed-repeat() is used without the correct number of parameters (i.e. odd numbers >= 3) is not caught and does not produce an error message.

Steps to reproduce the problem

Try to upload the following form: ET-CRVS-KAP-Questionnaire-v4-jef.xlsx to XLSForm Online. It should produce an error message, but doesn't. Instead, an error appears when loading in Enketo afterwards.

Expected behavior

The error is caught and an error message is presented.

Other information

The following message appears after converting using XLSForm online and loading in Enketo:

FormLogicError: indexed repeat with incorrect number of parameters found: indexed-repeat( /ET-CRVS-KAP-Questionnaire-v4-jef/child_u6/PCGfirstname_lab , /ET-CRVS-KAP-Questionnaire-v4-jef/child_u6 , /ET-CRVS-KAP-Questionnaire-v4-jef/random_Index ,1)

This should not happen in Enketo, but should happen at the time that ODK Validate (or PyXform) is run.

Also filed at PyXform: https://github.com/XLSForm/pyxform/issues/243

lognaturel commented 5 years ago

The full expression is if((${list_eligibleCG_Index} != ''), indexed-repeat(${PCGfirstname_lab} ,${child_u6},${random_Index},1),''). This is not identified as problematic by Validate because Validate doesn't actually do a syntax check, it runs through the form as a client would but without filling out any values. That means it doesn't hit the if path with the problematic indexed-repeat call.

I bet this is exactly what's going on with https://github.com/opendatakit/javarosa/issues/480#issue-490457627 -- it's probably a nested if that has the problem.

I just added a commit to https://github.com/opendatakit/validate/pull/78 to at least explain this behavior. I'll need to keep thinking about what we can/should do about the broader issue and have filed https://github.com/opendatakit/javarosa/issues/481 since it will need to be addressed in JavaRosa.

joeflack4 commented 5 years ago

Ahhhh, I see. Yes, opendatakit/javarosa#481 looks like the super fix to this problem.