Skip to content

fix(remote-config): don't sync a cold read for the previous user on identity change#3722

Draft
tonidero wants to merge 1 commit into
mainfrom
fix_remote_config_stale_user_on_demand_sync
Draft

fix(remote-config): don't sync a cold read for the previous user on identity change#3722
tonidero wants to merge 1 commit into
mainfrom
fix_remote_config_stale_user_on_demand_sync

Conversation

@tonidero

@tonidero tonidero commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Why

On an identity change, IdentityManager wiped remote config before caching the new app user ID. A cold topic()/blobData() read racing that change could trigger an on-demand sync for the previous user and, because that request starts after the cache is wiped, persist the wrong user's config into the new user's freshly-wiped cache and return it. This violates the offerings-parity invariant clearCache() exists to protect (config must never bleed across users).

The path is currently latent (the topic()/blobData() facade has no production callers yet), but it's a landmine for the first consumer.

Fix

clearCache() now binds the incoming app user to the drop-epoch atomically, and cold on-demand reads sync for that bound identity rather than the potentially-stale cached ID.

…yncs for the previous user

On an identity change IdentityManager wiped remote config before caching the
new app user ID, so a cold topic()/blobData() read racing the change could
trigger an on-demand sync for the previous user and repopulate the freshly
wiped cache with the wrong user's config. clearCache() now binds the new user
atomically with the epoch bump, and on-demand reads sync for that bound
identity rather than the potentially-stale cached ID.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tonidero tonidero added pr:fix A bug fix feat:remote-config pr:other and removed pr:fix A bug fix labels Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.48%. Comparing base (7d93941) to head (a3dcb44).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...m/revenuecat/purchases/identity/IdentityManager.kt 0.00% 0 Missing and 3 partials ⚠️
...rchases/common/remoteconfig/RemoteConfigManager.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3722   +/-   ##
=======================================
  Coverage   80.48%   80.48%           
=======================================
  Files         403      403           
  Lines       16717    16718    +1     
  Branches     2386     2386           
=======================================
+ Hits        13455    13456    +1     
  Misses       2322     2322           
  Partials      940      940           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant