Skip to content

dataconnect(change): Implement FetchPolicy.CACHE_ONLY#7875

Merged
dconeybe merged 4 commits into
mainfrom
dconeybe/dataconnect/FetchPolicy1
Mar 6, 2026
Merged

dataconnect(change): Implement FetchPolicy.CACHE_ONLY#7875
dconeybe merged 4 commits into
mainfrom
dconeybe/dataconnect/FetchPolicy1

Conversation

@dconeybe
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe commented Mar 5, 2026

This PR implements dataconnect support for the FetchPolicy.CACHE_ONLY fetch policy for queries. It introduces the CachedDataNotFoundException which is thrown when a query executed with CACHE_ONLY cannot find its data in the local cache, and updates the core execution paths to accept and properly route this fetch policy.

Highlights

  • FetchPolicy.CACHE_ONLY Support: Implemented handling for the FetchPolicy.CACHE_ONLY fetch policy across the core execution layer (DataConnectGrpcClient, DataConnectGrpcRPCs), ensuring queries can be executed strictly against the local cache.
  • CachedDataNotFoundException: Added a new exception type, CachedDataNotFoundException, thrown when CACHE_ONLY is requested but the data is absent or expired in the local cache (will be changed to absent ONLY).
  • Testing Enhancements: Added comprehensive unit tests to verify the correct behavior of the new fetch policy, and introduced new Kotest arbitrary tuple generators for more robust property-based testing.
Changelog
  • CHANGELOG.md
    • Updated PR number for offline caching APIs.
  • CachedDataNotFoundException.kt
    • Added CachedDataNotFoundException to be thrown when CACHE_ONLY fetch policy fails to find cached data.
  • DataConnectGrpcClient.kt
    • Updated executeQuery to accept a FetchPolicy parameter and pass it to DataConnectGrpcRPCs.
  • DataConnectGrpcRPCs.kt
    • Updated executeQuery to accept a FetchPolicy parameter and throw CachedDataNotFoundException if the policy is CACHE_ONLY.
  • QueryRefImpl.kt
    • Updated execute methods to pass the specified FetchPolicy to the QueryManager.
  • QuerySubscriptionImpl.kt
    • Updated to import FetchPolicy.
  • DataConnectGrpcClientUnitTest.kt
    • Added tests to verify executeQuery sends the correct FetchPolicy and updated existing tests to accommodate the new parameter.
  • DataConnectGrpcRPCsUnitTest.kt
    • Added a test to verify CachedDataNotFoundException is thrown for the CACHE_ONLY fetch policy when there is no cached data.
    • Added tests covering combinations of FetchPolicy conditions.
  • QueryRefImplUnitTest.kt
    • Added tests to verify execute forwards the correct FetchPolicy.
  • tuples.kt
    • Added Kotest arbitrary generators for quadruple and quintuple tuples to support complex property-based testing.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

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

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.

@dconeybe dconeybe force-pushed the dconeybe/dataconnect/FetchPolicy1 branch from a814eda to 41f9029 Compare March 5, 2026 23:14
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 5, 2026

📝 PRs merging into main branch

Our main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released.

@dconeybe
Copy link
Copy Markdown
Contributor Author

dconeybe commented Mar 5, 2026

/gemini review

Copy link
Copy Markdown
Contributor

@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 successfully implements the FetchPolicy.CACHE_ONLY feature for DataConnect queries, appropriately handling CachedDataNotFoundException for cache misses and enhancing robustness with updated unit tests. However, a critical security vulnerability was identified: sensitive query variables are included in the CachedDataNotFoundException message and logged at a warn level, which could lead to PII leakage in application logs. It is recommended to remove these variables from the exception message. Additionally, there are a couple of minor suggestions to improve code style.

@dconeybe dconeybe marked this pull request as ready for review March 6, 2026 02:07
@dconeybe dconeybe merged commit 93a18a0 into main Mar 6, 2026
43 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/FetchPolicy1 branch March 6, 2026 16:53
@github-actions github-actions Bot mentioned this pull request Mar 7, 2026
@firebase firebase locked and limited conversation to collaborators Apr 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants