dataconnect(change): Implement FetchPolicy.CACHE_ONLY#7875
Conversation
Using Gemini Code AssistThe 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
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 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. |
a814eda to
41f9029
Compare
📝 PRs merging into main branchOur 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. |
|
/gemini review |
There was a problem hiding this comment.
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.
…wn CachedDataNotFoundException
This PR implements dataconnect support for the
FetchPolicy.CACHE_ONLYfetch policy for queries. It introduces theCachedDataNotFoundExceptionwhich is thrown when a query executed withCACHE_ONLYcannot find its data in the local cache, and updates the core execution paths to accept and properly route this fetch policy.Highlights
FetchPolicy.CACHE_ONLYfetch policy across the core execution layer (DataConnectGrpcClient,DataConnectGrpcRPCs), ensuring queries can be executed strictly against the local cache.CachedDataNotFoundException, thrown whenCACHE_ONLYis requested but the data is absent or expired in the local cache (will be changed to absent ONLY).Changelog
CachedDataNotFoundExceptionto be thrown whenCACHE_ONLYfetch policy fails to find cached data.executeQueryto accept aFetchPolicyparameter and pass it toDataConnectGrpcRPCs.executeQueryto accept aFetchPolicyparameter and throwCachedDataNotFoundExceptionif the policy isCACHE_ONLY.executemethods to pass the specifiedFetchPolicyto theQueryManager.FetchPolicy.executeQuerysends the correctFetchPolicyand updated existing tests to accommodate the new parameter.CachedDataNotFoundExceptionis thrown for theCACHE_ONLYfetch policy when there is no cached data.FetchPolicyconditions.executeforwards the correctFetchPolicy.quadrupleandquintupletuples to support complex property-based testing.