Skip to content

Conversation

@franm91
Copy link
Member

@franm91 franm91 commented Jan 23, 2026


Open with Devin

Summary by CodeRabbit

  • Bug Fixes

    • Fixed KYC query cache invalidation so KYC state is correctly refreshed after app version updates.
  • Improvements

    • Enhanced cache persistence and restore behavior to avoid stale query data across releases and ensure consistent data after upgrades.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 68e5691

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link

Summary of Changes

Hello @franm91, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust mechanism for managing client-side data caching across application versions. By implementing version-aware deserialization and integrating a release identifier, the system can now automatically invalidate specific cached queries, such as KYC data, when the application updates. This prevents the use of stale or incompatible data, ensuring data integrity and a consistent user experience after new deployments.

Highlights

  • Version-Aware Cache Invalidation: Implemented a new versionAwareDeserialize function to intelligently handle the deserialization of the query client cache. This function checks the application's release version (buster) and, if a version change is detected, selectively invalidates specified queries.
  • Targeted Query Invalidation: Introduced an INVALIDATE_ON_UPGRADE set, currently configured to invalidate the 'kyc' query. This ensures that sensitive or version-dependent data like KYC information is always fresh after an application update.
  • Release Version Integration: Integrated the application's release version into the persistQueryClientRestore and persister.persistClient calls. This buster mechanism allows the caching system to detect when the application has been updated, triggering the version-aware invalidation logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sentry
Copy link

sentry bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.87%. Comparing base (bc8ac76) to head (68e5691).

Files with missing lines Patch % Lines
src/utils/queryClient.ts 76.92% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   61.84%   61.87%   +0.02%     
==========================================
  Files         169      169              
  Lines        5289     5298       +9     
  Branches     1496     1497       +1     
==========================================
+ Hits         3271     3278       +7     
- Misses       1845     1848       +3     
+ Partials      173      172       -1     
Flag Coverage Δ
e2e 60.06% <76.92%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds version-aware cache deserialization to the QueryClient persistence layer: persisted state is annotated with a buster (current release), deserialization filters KYC-related queries when the buster differs from the running release, and the persisted buster is updated during hydration and save.

Changes

Cohort / File(s) Summary
Changeset
\.changeset/sharp-weeks-nail.md
Declares a patch release for @exactly/mobile and notes a bugfix to invalidate KYC queries on version change.
Query Client Persistence
src/utils/queryClient.ts
Adds versionAwareDeserialize(cache) and imports release; replaces persister.deserialize with versionAwareDeserialize; includes buster: release when restoring and persisting the query client; filters out KYC queries on buster mismatch and updates persisted buster to current release.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 🐛 app fixes #664: Modifies src/utils/queryClient.ts persistence/hydration behavior (related changes to restore and dehydrate options).

Suggested reviewers

  • dieguezguille
  • cruzdanilo
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: invalidating the KYC query on version changes, which is implemented through version-aware deserialization in queryClient.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cruzdanilo cruzdanilo changed the title Invalidate kyc query on version change 🐛 app: invalidate kyc query on version change Jan 23, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to invalidate the kyc query cache when the application version changes. It uses a version 'buster' string with the persisted query client and a custom deserialization function for selective cache invalidation. My review found a critical logical flaw in the custom deserializer that would cause the entire cache to be invalidated, instead of just the kyc queries. I've provided a code suggestion to fix this issue and ensure the intended behavior is achieved. The rest of the changes correctly support this new functionality.

Comment on lines 20 to 28
function versionAwareDeserialize(cache: string): PersistedClient {
const data: PersistedClient = deserialize(cache);
if (data.buster === release) return data;
data.clientState.queries = data.clientState.queries.filter(
(query) => !INVALIDATE_ON_UPGRADE.has(query.queryKey[0] as string),
);
return data;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The current implementation of versionAwareDeserialize correctly filters out stale queries, but it returns the PersistedClient object with its original (old) buster string. Subsequently, persistQueryClientRestore is called with the new release version as its buster parameter. This mismatch causes persistQueryClientRestore to invalidate the entire cache, which negates the selective invalidation logic.

To fix this, versionAwareDeserialize should return a new PersistedClient object that includes the updated buster value (release) along with the filtered queries. This ensures that persistQueryClientRestore sees a matching buster and preserves the rest of the cache.

Suggested change
function versionAwareDeserialize(cache: string): PersistedClient {
const data: PersistedClient = deserialize(cache);
if (data.buster === release) return data;
data.clientState.queries = data.clientState.queries.filter(
(query) => !INVALIDATE_ON_UPGRADE.has(query.queryKey[0] as string),
);
return data;
}
function versionAwareDeserialize(cache: string): PersistedClient {
const data: PersistedClient = deserialize(cache);
if (data.buster === release) return data;
return {
timestamp: data.timestamp,
buster: release,
clientState: {
mutations: data.clientState.mutations,
queries: data.clientState.queries.filter(
(query) => !INVALIDATE_ON_UPGRADE.has(query.queryKey[0] as string),
),
},
};
}

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 2 additional flags in Devin Review.

Open in Devin Review

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/utils/queryClient.ts`:
- Around line 20-27: versionAwareDeserialize currently filters out upgraded
queries but leaves data.buster unchanged so TanStack Query will discard the
whole cache; after filtering data.clientState.queries (using
INVALIDATE_ON_UPGRADE and query.queryKey) set data.buster = release before
returning so the deserialized PersistedClient (constructed via deserialize) is
recognized as valid; update the function versionAwareDeserialize to assign
data.buster = release after the filter and then return data.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/utils/queryClient.ts (1)

54-72: Pass buster: release to persistQueryClientSubscribe to prevent perpetual KYC invalidation.

Currently, persistQueryClientSubscribe is called without buster, so cache updates persist without a buster value. On app restart, persistQueryClientRestore restores with buster: release, but versionAwareDeserialize treats the stored cache as having an outdated buster and filters out KYC queries—causing KYC to be cleared every time the app launches.

🐛 Proposed fix
 if (typeof window !== "undefined") {
-  const subscribe = () => persistQueryClientSubscribe({ queryClient, persister, dehydrateOptions });
+  const subscribe = () =>
+    persistQueryClientSubscribe({ queryClient, persister, dehydrateOptions, buster: release });
   hydrated.then(subscribe, subscribe);
 }
🤖 Fix all issues with AI agents
In `@src/utils/queryClient.ts`:
- Around line 12-28: Rename the generic local variable "data" in function
versionAwareDeserialize to a descriptive name like "persistedClient": replace
the assignment const data = deserialize(cache) with const persistedClient =
deserialize(cache) and update all subsequent references (persistedClient.buster,
persistedClient.clientState.queries, persistedClient.buster = release) and the
function return to return persistedClient so the intent of the variable is clear
and consistent with the PersistedClient type.

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

Successfully merging this pull request may close these issues.

2 participants