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

XPath evaluation crash after wrong if function #6418

Open
dbemke opened this issue Sep 16, 2024 · 2 comments
Open

XPath evaluation crash after wrong if function #6418

dbemke opened this issue Sep 16, 2024 · 2 comments
Milestone

Comments

@dbemke
Copy link

dbemke commented Sep 16, 2024

ODK Collect version

the master version 66e9c1f

Android version

10, 14

Device used

Redmi 9T, Pixel 7a

Problem description

There’s a crash( Xpath evaluation) after opening a form with a wrong if statement. I’m not sure what should be expected – should an error appear on opening the form or if there’s other way to prevent the crash.
childUpdateCrash

It’s a form with the new spec so I attach both xml (to upload to Central) and
child updateCOnst.xml.txt
xlsx.
child updateCOnst.xlsx.txt

Steps to reproduce the problem

  1. Download the form.
  2. Open child update with const filter form
@lognaturel
Copy link
Member

I agree that it's surprising that it takes down the whole app. I would have expected the exception to be caught and shown in a dialog.

I'm not really understanding where the call originates from. Something in the background?

org.javarosa.xpath.XPathUnhandledException: XPath evaluation: cannot handle function 'if'. Requires 3 arguments but 1 provided.
	at org.javarosa.xpath.expr.XPathFuncExpr.assertArgsCount(XPathFuncExpr.java:540)
	at org.javarosa.xpath.expr.XPathFuncExpr.eval(XPathFuncExpr.java:165)
	at org.javarosa.core.model.condition.RawFilterStrategy.filter(RawFilterStrategy.java:32)
	at org.javarosa.core.model.condition.EvaluationContext.filterWithPredicate(EvaluationContext.java:382)
	at org.javarosa.core.model.condition.EvaluationContext.lambda$filterWithPredicate$0$org-javarosa-core-model-condition-EvaluationContext(EvaluationContext.java:383)
	at org.javarosa.core.model.condition.EvaluationContext$$ExternalSyntheticLambda0.get(D8$$SyntheticClass)
	at org.javarosa.core.model.ComparisonExpressionCacheFilterStrategy.filter(ComparisonExpressionCacheFilterStrategy.java:55)
	at org.javarosa.core.model.condition.EvaluationContext.filterWithPredicate(EvaluationContext.java:382)
	at org.javarosa.core.model.condition.EvaluationContext.lambda$filterWithPredicate$0$org-javarosa-core-model-condition-EvaluationContext(EvaluationContext.java:383)
	at org.javarosa.core.model.condition.EvaluationContext$$ExternalSyntheticLambda0.get(D8$$SyntheticClass)
	at org.javarosa.core.model.EqualityExpressionIndexFilterStrategy.filter(EqualityExpressionIndexFilterStrategy.java:33)
	at org.javarosa.core.model.condition.EvaluationContext.filterWithPredicate(EvaluationContext.java:382)
	at org.javarosa.core.model.condition.EvaluationContext.lambda$filterWithPredicate$0$org-javarosa-core-model-condition-EvaluationContext(EvaluationContext.java:383)
	at org.javarosa.core.model.condition.EvaluationContext$$ExternalSyntheticLambda0.get(D8$$SyntheticClass)
	at org.odk.collect.entities.javarosa.filter.LocalEntitiesFilterStrategy.filter(LocalEntitiesFilterStrategy.kt:66)
	at org.javarosa.core.model.condition.EvaluationContext.filterWithPredicate(EvaluationContext.java:382)
	at org.javarosa.core.model.condition.EvaluationContext.filterWithPredicate(EvaluationContext.java:377)
	at org.javarosa.core.model.condition.EvaluationContext.expandReferenceAccumulator(EvaluationContext.java:343)
	at org.javarosa.core.model.condition.EvaluationContext.expandReference(EvaluationContext.java:250)
	at org.javarosa.core.model.condition.EvaluationContext.expandReference(EvaluationContext.java:219)
	at org.javarosa.xpath.expr.XPathPathExprEval.eval(XPathPathExprEval.java:34)
	at org.javarosa.xpath.expr.XPathPathExpr.eval(XPathPathExpr.java:213)
	at org.javarosa.xpath.XPathConditional.evalNodeset(XPathConditional.java:94)
	at org.javarosa.core.model.ItemsetBinding.getChoices(ItemsetBinding.java:125)
	at org.javarosa.form.api.FormEntryPrompt.getSelectChoices(FormEntryPrompt.java:222)
	at org.javarosa.form.api.FormEntryPrompt.getAnswerValue(FormEntryPrompt.java:98)
	at org.odk.collect.android.formentry.audit.AuditUtils.logCurrentScreen(AuditUtils.kt:21)
	at org.odk.collect.android.formentry.FormEntryViewModel.updateIndex(FormEntryViewModel.java:351)
	at org.odk.collect.android.formentry.FormEntryViewModel.lambda$refresh$7(FormEntryViewModel.java:318)
	at org.odk.collect.android.formentry.FormEntryViewModel.$r8$lambda$IkEKpMouzOlAseG821xo_liby6A(FormEntryViewModel.java)
	at org.odk.collect.android.formentry.FormEntryViewModel$$ExternalSyntheticLambda10.get(D8$$SyntheticClass)
	at org.odk.collect.async.CoroutineScheduler$immediate$1$result$1.invokeSuspend(CoroutineScheduler.kt:18)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:111)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:99)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)

@lognaturel lognaturel added this to the v2024.3 milestone Sep 23, 2024
@lognaturel
Copy link
Member

@grzegorz mentions there was a recent change to how exceptions are handled in this area. We should at least explore whether this is a change in behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: not ready
Development

No branches or pull requests

2 participants