Skip to content

fix(settings): prevent refresh from overwriting migrated or pending values #151

Open

Description

@Quick104

Problem

Current main copies legacy and renamed settings into DataStore, but it does not establish those recovered values on the server before a canonical refresh applies effective values:

  • migrateLegacyCache imports locally only: AndroidPlayerSettingsStore.kt:122-140
  • migrateRenamedKeys copies the renamed slots locally only: AndroidPlayerSettingsStore.kt:154-167
  • refreshFromServer immediately reads effective values without coordinating with pending writes: AndroidPlayerSettingsStore.kt:530-538
  • applyEffectiveLocally then writes returned contract defaults over local slots: AndroidPlayerSettingsStore.kt:610-627

The deterministic upgrade case is a pre-rename player.next_up_prompt_seconds value when the server has no canonical override: migration copies it, the effective GET returns the default 30, and the refresh overwrites the recovered value. The same ordering problem applies to legacy-cache imports and to a recent local edit still behind the flusher debounce.

PR #101 identified and tested this race, but its implementation targets the pre-#119 settings architecture and must not be cherry-picked as-is.

Expected behavior

  • Recovered values for canonical remote keys are enqueued with the correct type and server origin.
  • Renamed keys cover both current entries in PlaybackSettingsKeys.RenamedLocalKeys.
  • Granular local subtitle fields are not sent as unknown canonical keys; preserve the composite projection behavior.
  • A refresh cannot overwrite a newer pending/retryable local operation with an older server value or a contract default.
  • Transient flush failures do not silently discard or overwrite the local value.
  • Reset flows still intentionally hydrate contract defaults after successful deletes.
  • Tests cover the production scoped-key prefix, rename migration, legacy-cache import, pending-write ordering, and failure behavior.

Context: #101, #119

Activity

  1. added
    bug
    triaged
    and removed
    triaged
    on Sep 20, 2026
  2. added theissue type on Sep 20, 2026
  3. removed
    bug
    on Sep 20, 2026
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

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions