Skip to content

Watch remote synchronization fails with duplicate Outcome. #700

@Dlemex

Description

@Dlemex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions