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
Duplicate UUIDs when same draft loaded multiple times #942
Comments
I agree there’s a problem here. Users do open a draft in one tab, forget about it, open it in another tab as well, and end up in an inconsistent state. That said, I think the current behavior is consistent with a draft concept without any kind of edit lock. What you describe feels more like a “clone and complete.” Is that the goal you have? You want to be able to partially fill out a record and then spin off clones that actually represent different submissions? If you start with one locally-saved record, open it in 5 tabs, save each, would you expect 5 or 6 local records with this feature? |
Right, I think this is the main problem. Maybe power users are doing "clone and complete"—and I'm trying to find out—but I'm mostly concerned about people accidentally getting into a state where they are unknowingly sending duplicate UUIDs. One project I was investigating had 15% of its submissions contain duplicate UUIDs.
I would be happy if Enketo blocked me from opening that one locally-saved record in more than one tab simultaneously. That kind of locking feels elegant, but I don't know how much of a pain it would be to implement. Other use cases are interesting, but I don't see them as part of this bug report. I would like to prioritize preventing Enketo from reusing the same UUID when sending submissions with disparate response data. I think Central has always had good hygiene by rejecting duplicate UUIDs with HTTP 409, blocking "clone and complete" as someone might attempt it with today's Enketo. Kobo has been very permissive and accepted almost anything that a client would send, but we are tightening things up because we increasingly rely on the UUID being a truly unique identifier. Thanks for responding so quickly, and I look forward to reading your thoughts. |
I believe this is solvable without locking, by moving this offline storage logic to the offline service worker, because there’s only ever a single instance of a service worker running at any given time, regardless of how many open tabs depend on it. This dovetails well with other ongoing work to move several other offline storage concerns—for instance, caching of media (#464) and forms—to the service worker as well, so we’ll probably address this in that context/scope. These changes, especially combined, will also allow us to significantly reduce the complexity of offline-capable mode. I’ll be on vacation over the next month, but I intend to pick this back up when I get back. |
Describe the bug
If someone opens the same form more than once within the same browser session, and then loads the same draft in multiple tabs or windows, the submissions created from those drafts will have the same UUID.
To Reproduce
No special form is needed. I tested with a single
decimal
question.autosave successful
in the console)properties
, by looking at thesubmitted
array within<survey ID>:stats
Expected behavior
The two submissions would have unique UUIDs.
Screenshots
Browser and OS (please complete the following information):
Additional context
The same is true for named drafts (created with the "Save Draft") button as well as autosaved drafts.
I identified this code path for UUID generation:
For loading a (named) draft:
The text was updated successfully, but these errors were encountered: