dataconnect(change): Internal refactor to use immutable byte arrays when calculating SHA512 hashes#7957
Conversation
…ray (instead of ByteArray)
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. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the codebase to consistently use ImmutableByteArray for SHA-512 digests and query IDs, enhancing immutability and type safety. This involves updating DataConnectGrpcRPCs, LiveQueries, LiveQuery, and ProtoUtil to directly handle ImmutableByteArray for hash values. New tests were added for ImmutableByteArray's alphanumeric string conversion. Feedback includes updating a changelog placeholder, using named arguments for LiveQuery.Key for improved readability and maintainability, and correcting the documentation for AlphanumericStringUtil.toAlphaNumericString to accurately describe the custom base-32 alphabet used.
📝 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. |
This PR refactors the internal hashing logic within the
firebase-dataconnectmodule by migrating from mutable byte arrays toImmutableByteArray. This change reinforces the immutability of internally calculated SHA-512 hashes for ProtobufStructandValuetypes, which are used to represent query IDs and variable hashes.Highlights
calculateSha512extension functions forStructandValueto returnImmutableByteArrayinstead of primitiveByteArray.variablesHashfield inLiveQuery.KeyfromStringtoImmutableByteArrayto leverage the new immutable return type.toAlphaNumericString()extension forImmutableByteArrayinAlphanumericStringUtiland fixed a documentation typo (base-32 instead of base-36).AlphanumericStringUtilUnitTest.ktwith property-based testing to verify that the newtoAlphaNumericString()extension function correctly formatsImmutableByteArrays without mutating the underlying array.Changelog
calculateSha512function returning anImmutableByteArray.ImmutableByteArraydirectly.variablesHashinLiveQuery.KeyfromStringtoImmutableByteArray.toAlphaNumericString()extension function forImmutableByteArray.calculateSha512forStructandValuetoImmutableByteArray.toAlphaNumericString()behavior and array safety forImmutableByteArray.