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

Draft with no actual file is created when there is a crash during finalization #6522

Open
seadowg opened this issue Nov 20, 2024 · 1 comment

Comments

@seadowg
Copy link
Member

seadowg commented Nov 20, 2024

This is challenging to reproduce as there are no known routes to causing a crash during form finalization. However, any future bugs that do end up causing a crash here will lead to a really confusing scenario.

The easiest way to simulate the scenario is to change the above linked line to throw new IllegalStateException(). Then carry out the following steps:

  1. Start a new form, go to the end screen and hit finalize
  2. Open Drafts
  3. Click on the new draft

You'll see that there is an error and the draft then disappears. This is because the instances DB gets updated with the new instance, but the submission XML itself is never written to disk so the (correct) error handling that accounts for this scenario (instance in the DB, but not on disk) kicks and fixes the mismatch.

Instead of this, if there is a crash while finalizing, no draft should be created.

@seadowg seadowg moved this from inbox to later in ODK Collect Nov 20, 2024
@seadowg seadowg moved this from later to ready in ODK Collect Nov 20, 2024
@lognaturel
Copy link
Member

lognaturel commented Nov 21, 2024

If I start with a blank form and get into this state, I do get a savepoint. If I open the "ghost draft" before I open the savepoint, I get an error when trying to save a draft from that savepoint:

java.io.FileNotFoundException: /storage/emulated/0/Android/data/org.odk.collect.android/files/projects/DEMO/instances/All question types_2024-11-21_10-27-13/All question types_2024-11-21_10-27-13.xml: open failed: ENOENT (No such file or directory)
   at libcore.io.IoBridge.open(IoBridge.java:574)
   at java.io.FileOutputStream.<init>(FileOutputStream.java:259)
   at java.io.FileOutputStream.<init>(FileOutputStream.java:208)
   at org.odk.collect.shared.files.FileExt.saveToFile(FileExt.kt:49)
   at org.odk.collect.android.tasks.SaveFormToDisk.writeFile(SaveFormToDisk.java:489)

This feels like the worst part of this whole situation.

If I don't open the "ghost draft" first, I can open the savepoint and save it as draft.

What I was most worried about was if you had saved a draft, made edits to that draft, and then attempted to finalize. It looks like that does save the updates as draft which is good.

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

No branches or pull requests

2 participants