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

Watch remote synchronization fails with duplicate Outcome. #700

Open
Dlemex opened this issue Jun 22, 2023 · 0 comments
Open

Watch remote synchronization fails with duplicate Outcome. #700

Dlemex opened this issue Jun 22, 2023 · 0 comments

Comments

@Dlemex
Copy link

Dlemex commented Jun 22, 2023

There is an error in the CareKitStore: OCKCDOutcome validateForInsert() function. During synchronization, it is possible for two outcomes for the same task/taskOccurrenceIndex values where one is the previous outcome. The validation correctly handles the case where the next set is empty. However, when the validation occurs for the previous outcome, the validation will see the other outcome as a duplicate outcome.

This issue has been dogging me since version 2.x, and I finally tracked it down. The solution is to add after the guard let:

   if next.count > 0 {
      return
   }

However, before fixing this, the context save in synchronization failing (due to the duplicate outcome) would break future synchronization attempts. The next synchronization attempt would crash because the task is missing when creating an outcome (when the task is forcibly unwrapped). As the above fixes my issue, I did not investigate further, but there seems to be an issue if the try self.context.save() fails in pullThenPush(completion:) step #5.

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

No branches or pull requests

1 participant