Conversation
…enResult objects instead of raw strings for better type safety [skip actions]
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. |
📝 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 refactors the DataConnect gRPC client to use token objects instead of strings for authentication and AppCheck. It updates the gRPC metadata handling to include auth UIDs in logs and improves the robustness of the gRPC retry logic by passing tokens explicitly. I have one suggestion regarding the putHeaders function to ensure consistency in how auth UIDs are handled across different logging methods.
...-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/DataConnectGrpcMetadata.kt
Outdated
Show resolved
Hide resolved
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the DataConnect gRPC client to centralize authentication and app check token handling. Token fetching and refresh logic are now managed within DataConnectGrpcClient's retryOnGrpcUnauthenticatedError method, which passes tokens explicitly to DataConnectGrpcRPCs and DataConnectGrpcMetadata. This involved updating method signatures, removing token fetching logic from DataConnectGrpcMetadata, and adjusting constructor parameters. Corresponding test files were updated to reflect these changes, including new test utilities for token handling. A CHANGELOG.md entry was added. Feedback includes a question about the intentional removal of fetchPolicy validation, a suggestion for cleaner authUid logging, and a redundant iterator() extension function in test utilities.
...base-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/DataConnectGrpcRPCs.kt
Show resolved
Hide resolved
...-dataconnect/src/main/kotlin/com/google/firebase/dataconnect/core/DataConnectGrpcMetadata.kt
Show resolved
Hide resolved
...stutil/src/main/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary/tuples.kt
Outdated
Show resolved
Hide resolved
…or(): Iterator<T>`
This PR refactors the internal Data Connect gRPC client and metadata handling to pass around token objects (
GetAuthTokenResult,GetAppCheckTokenResult) instead of raw strings. This improves type safety and simplifies the logic for retrying requests on authentication errors, as the token retrieval and metadata construction are now more decoupled and robust.Highlights
GetAuthTokenResultandGetAppCheckTokenResultobjects acrossDataConnectGrpcClient,DataConnectGrpcRPCs, andDataConnectGrpcMetadata.retryOnGrpcUnauthenticatedErrorinDataConnectGrpcClientto retrieve fresh tokens before retrying, ensuring that authentication failures are handled correctly with up-to-date credentials.DataConnectGrpcMetadatato accept token objects directly in itsgetmethod, and added support for includingauthUidin scrubbed debug logs.DataConnectGrpcClientUnitTest,DataConnectGrpcMetadataUnitTest, andDataConnectGrpcRPCsUnitTestto reflect the new token-based architecture and ensure comprehensive coverage of the refactored paths.Changelog
Details
retryOnGrpcUnauthenticatedErrorto handle token refresh more effectively.getto accept token objects and updatedtoStructPrototo includeauthUidin scrubbed auth token headers for better debugging.executeQueryandexecuteMutationsignatures to acceptGetAuthTokenResultandGetAppCheckTokenResult.DataConnectArbextension functions to support generating token results and updateddataConnectGrpcMetadataarb.MultipleValuesinterface to simplify collection-based operations on custom tuple types used in property testing.