Skip to content

Harden Core Data mapping against duplicate UUID crash loops #83

Description

@barronlroth

Parent: #82
Related: #81

Problem

CoreDataAppRepository builds home and location lookup dictionaries with Dictionary(uniqueKeysWithValues:). If CloudKit import, migration retry, or partial share state ever leaves duplicate CDHome.id or CDStorageLocation.id values in the local store, this call traps instead of throwing.

That is a plausible persistent launch/use crash-loop vector because AppStore.refresh() runs during app startup and refreshes again after remote changes.

Proposed work

  • Replace Dictionary(uniqueKeysWithValues:) in repository mapping with duplicate-aware grouping.
  • Log duplicate entity type, UUID, objectID URI, and persistent store scope.
  • Pick a deterministic survivor for UI mapping or skip ambiguous records without crashing.
  • Decide whether duplicate records should be repaired automatically or only surfaced as diagnostics.
  • Add regression tests that insert duplicate home/location UUIDs and prove listHomes(), listLocations(), and AppStore.refresh() do not trap.

Acceptance criteria

  • Duplicate Core Data UUIDs cannot crash the app during refresh or launch.
  • Duplicate state produces actionable logs.
  • Tests cover duplicate homes and duplicate locations across private/shared-store style data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions