Skip to content

Conversation

@dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Dec 18, 2025

This PR implements an internal refactoring within the firebase-dataconnect module, moving from a string-based representation of proto struct paths to a more structured and type-safe DataConnectPath (a list of DataConnectPathSegment objects). This change improves the robustness and maintainability of path handling throughout the module, particularly in areas related to serialization, deserialization, and error reporting. The refactor introduces a set of utility functions for path manipulation, ensuring consistent and correct path construction and representation.

Highlights

  • Path Type Refactor: The internal representation of "paths" has been refactored from simple String? to a more robust and type-safe DataConnectPath (an alias for List<DataConnectPathSegment>).
  • Path Manipulation Utilities: New extension functions have been introduced for DataConnectPath to facilitate common operations like converting paths to strings (toPathString, appendPathStringTo) and safely adding new segments (addField, addListIndex, withAddedPathSegment).
  • Serialization/Deserialization Updates: The ProtoStructDecoder, ProtoStructEncoder, and ProtoUtil classes have been updated to leverage the new DataConnectPath type and its associated utility functions, improving consistency and error reporting.
  • Error Reporting Enhancement: The ErrorInfoImpl.toString() method now uses the new path string conversion utilities, ensuring consistent and accurate path representation in error messages.
  • Comprehensive Testing: Extensive unit tests have been added and updated for the new path extension functions and the overall path handling logic, including property-based testing.
Changelog
  • CHANGELOG.md
    • Added an entry for the internal refactor related to reporting "paths" in response data.
  • DataConnectPathSegment.kt
    • Introduced DataConnectPath type alias and extension functions for path string conversion and segment addition.
  • DataConnectOperationFailureResponseImpl.kt
    • Updated ErrorInfoImpl.toString() to use the new appendPathStringTo function for path formatting.
  • ProtoStructDecoder.kt
    • Modified decode functions and decoder classes to accept DataConnectPath instead of String? for path parameters, integrating new path manipulation functions.
  • ProtoStructEncoder.kt
    • Updated encoder classes to use DataConnectPath for path parameters and leverage new path extension functions.
  • ProtoUtil.kt
    • Adjusted ProtoValueEncoder and ProtoValueDecoder instantiation to use emptyList() for initial paths.
  • DataConnectPathSegmentUnitTest.kt
    • Added new unit tests for DataConnectPathSegment extension functions, covering toPathString, appendPathStringTo, addField, addListIndex, withAddedField, withAddedListIndex, and withAddedPathSegment.
  • DataConnectSettingsUnitTest.kt
    • Updated Arb.dataConnect.errorPath() to Arb.dataConnect.dataConnectPath().
  • DataConnectOperationFailureResponseImplUnitTest.kt
    • Replaced errorPathArb with dataConnectPathArb and simplified toString() tests to use the new toPathString function.
    • Removed MyArb utility object.
  • testutil/src/main/.../arbs.kt
    • Replaced errorPath with dataConnectPath and introduced DataConnectPathArb for more controlled generation of DataConnectPath instances in property-based tests.

@github-actions

This comment was marked as off-topic.

Copy link
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 is a great internal refactoring that introduces higher-level types for handling proto struct paths. Replacing string-based path manipulation with the DataConnectPathSegment sealed interface and its associated helper functions makes the code more robust, type-safe, and easier to maintain. The changes are consistently applied across the decoders, encoders, and error reporting logic. The addition of comprehensive property-based tests for the new path utilities is also a big plus.

I've found a couple of very minor issues, mostly typos, which I've commented on. Overall, this is excellent work!

@google-oss-bot

This comment was marked as off-topic.

@google-oss-bot

This comment was marked as off-topic.

@firebase firebase deleted a comment from gemini-code-assist bot Dec 18, 2025
@firebase firebase deleted a comment from gemini-code-assist bot Dec 18, 2025
@dconeybe dconeybe marked this pull request as ready for review December 18, 2025 19:31
@dconeybe dconeybe merged commit a41dfcf into main Dec 19, 2025
42 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/ProtoPath branch December 19, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants