Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Issue 831 ignore failing forms on startup #836

Merged
merged 8 commits into from
Nov 20, 2019
Merged

Issue 831 ignore failing forms on startup #836

merged 8 commits into from
Nov 20, 2019

Conversation

ggalmazor
Copy link
Contributor

Closes #831

What has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

This is a straightforward change to ignore forms that can't be parsed while sync'ing files from the storage directory.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

This should solve the issue. Users should expect a new log message "Couldn't parse form at /foo/ODK Briefcase Storage/forms/bar/bar.xml" each time Briefcase isn't able to sync a form for parsing reasons. The full stacktrace would include the causing error. In this case, having replaced the last > with a ? character:

2019-11-19 15:25:57,597 [main] ERROR o.o.b.m.f.FileSystemFormMetadataAdapter - Couldn't parse form at /tmp/cocotero/ODK Briefcase Storage/forms/fieldListSimpleTest/fieldListSimpleTest.xml
org.opendatakit.briefcase.reused.BriefcaseException: org.xmlpull.v1.XmlPullParserException: expected: '>' actual: '?' (position:END_TAG </h:html>@1:1553 in java.io.InputStreamReader@5bf8fa12) 
	at org.opendatakit.briefcase.export.XmlElement.from(XmlElement.java:94)
	at org.opendatakit.briefcase.model.form.FileSystemFormMetadataAdapter.isAForm(FileSystemFormMetadataAdapter.java:87)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.opendatakit.briefcase.model.form.FileSystemFormMetadataAdapter.syncWithFilesAt(FileSystemFormMetadataAdapter.java:74)
	at java.base/java.util.Optional.ifPresent(Optional.java:183)
	at org.opendatakit.briefcase.ui.MainBriefcaseWindow.<init>(MainBriefcaseWindow.java:115)
	at org.opendatakit.briefcase.ui.MainBriefcaseWindow.launchGUI(MainBriefcaseWindow.java:94)
	at org.opendatakit.briefcase.Launcher.lambda$main$0(Launcher.java:78)
	at org.opendatakit.common.cli.Cli.lambda$run$5(Cli.java:136)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.opendatakit.common.cli.Cli.run(Cli.java:136)
	at org.opendatakit.briefcase.Launcher.main(Launcher.java:90)
Caused by: org.xmlpull.v1.XmlPullParserException: expected: '>' actual: '?' (position:END_TAG </h:html>@1:1553 in java.io.InputStreamReader@5bf8fa12) 
	at org.kxml2.io.KXmlParser.exception(Unknown Source)
	at org.kxml2.io.KXmlParser.error(Unknown Source)
	at org.kxml2.io.KXmlParser.read(Unknown Source)
	at org.kxml2.io.KXmlParser.parseEndTag(Unknown Source)
	at org.kxml2.io.KXmlParser.nextImpl(Unknown Source)
	at org.kxml2.io.KXmlParser.nextToken(Unknown Source)
	at org.kxml2.kdom.Element.parse(Unknown Source)
	at org.kxml2.kdom.Node.parse(Unknown Source)
	at org.kxml2.kdom.Element.parse(Unknown Source)
	at org.kxml2.kdom.Node.parse(Unknown Source)
	at org.kxml2.kdom.Document.parse(Unknown Source)
	at org.opendatakit.briefcase.export.XmlElement.from(XmlElement.java:91)
	... 20 common frames omitted

Does this change require updates to documentation? If so, please file an issue at https://github.com/opendatakit/docs/issues/new and include the link below.

By duplicating the arg, we can move the XmlElement.from(path) inside the method and handle any exception that is thrown by that, encapsulating the whole check.
Extract the variable into a second variable to be able to replace its value by XmlElement.from(path) and thus make the root arg redundant
Make the root arg redundant
Remove unused arg
Replace by method reference
@ggalmazor ggalmazor added this to the v1.17.1 milestone Nov 19, 2019
Copy link
Member

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

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

Code looks straightforward and good. @grzesiek2010 could you please verify that it fixes the case you reproduced? I think that's sufficient QA but let's see if @kkrawczyk123 agrees!

@grzesiek2010
Copy link
Member

It looks and works well. @kkrawczyk123 if you are free and really want to confirm please fell free if not we'll merge.

@kkrawczyk123
Copy link
Contributor

Confirmed on all systems.
@opendatakit-bot label "behavior verified"

@ggalmazor ggalmazor merged commit 8f78fd7 into getodk:master Nov 20, 2019
@ggalmazor ggalmazor deleted the issue_831_ignore_failing_forms_on_startup branch November 20, 2019 14:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't open Briefcase if one of the forms is broken
5 participants