fix(firestore): read and write user data on pipeline execute#9715
fix(firestore): read and write user data on pipeline execute#9715
Conversation
🦋 Changeset detectedLatest commit: b1944ac The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the Firestore pipeline to defer the reading and writing of user data until the pipeline's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request refactors the Firestore pipeline implementation by removing UserDataReader and UserDataWriter parameters from Pipeline and PipelineSource constructors and related methods. The Pipeline class now implements a UserData interface and includes a new _readUserData method, centralizing the data reading logic by iterating through its stages. Consequently, explicit userDataReader context creation and _readUserData calls are removed from individual pipeline stage creation methods. The execute functions in pipeline_impl.ts now handle userDataWriter instantiation and pipeline._readUserData calls locally, streamlining the pipeline's internal data handling.
Note: Security Review is unavailable for this PR.
7e91482 to
5907bba
Compare
5907bba to
04328c7
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the Firestore pipeline to defer user data validation from stage initialization to the execute() call. The changes are consistently applied throughout the codebase, including necessary updates to public API definitions and test files. The implementation is clean and aligns with the described goals. I've identified a minor issue in the updated test cases where they don't fail if the execute() call unexpectedly succeeds, and I've provided suggestions to correct this.
| const udr = new UserDataReader( | ||
| firestore._databaseId, | ||
| /* ignoreUndefinedProperties */ true | ||
| const userDataReader = newUserDataReader(firestore); |
There was a problem hiding this comment.
note that this is now inheriting the ignoreUndefinedProperties config from the firestore instance, instead of setting it to true.
04328c7 to
b654f35
Compare
MarkDuckworth
left a comment
There was a problem hiding this comment.
LGTM. Other than allowing subcollection, this feels like a nice cleanup
| const udr = new UserDataReader( | ||
| firestore._databaseId, | ||
| /* ignoreUndefinedProperties */ true | ||
| const userDataReader = newUserDataReader(firestore); |
DellaBitta
left a comment
There was a problem hiding this comment.
Nit: Ensure the changeset matches the release notes that you want on devsite.
Adds a step to `internalPipelineToExecutePipelineRequestProto` to read user data before serialization. This function was broken in #9715, and caused the `console support` tests to fail, which use this method to verify pipelines get serialized as expected. These test failures weren't caught since they weren't run in CI, and were skipped when ran locally with `test:lite` and `test:browser`. I verified these tests now pass using `test:node:prod`.
Adds a step to `internalPipelineToExecutePipelineRequestProto` to read user data before serialization. This function was broken in #9715, and caused the `console support` tests to fail, which use this method to verify pipelines get serialized as expected. These test failures weren't caught since they weren't run in CI, and were skipped when ran locally with `test:lite` and `test:browser`. I verified these tests now pass using `test:node:prod`.
To support standalone stage initializers (such as
subcollection()), that can be constructed without an existing pipeline, we need to decouple stage initialization and user data validation. Standalone functions do not have access toFirestoreordatabaseIdcontext when called, so validation must be deferred until the pipeline is executed withexecute(pipeline).Implementation Details:
select,where,addFields, ...)._readUserData()traversal toPipelineclass.execute()to triggerpipeline._readUserData()before executing the pipeline.Breaking Changes:
Errors regarding invalid user data in stages will now be thrown when
execute(pipeline)is called, rather than during the initialization of the stage (pipeline.collection().addFields(/* invalid data */)).This aligns with the behaviour on both iOS, Android, and Java SDKs.
undefinedonrawOptionsthrowsInner object properties that are
undefinedinsiderawOptionswill now cause validation to fail, instead of being silently ignored. This is a side effect of execution parsing. Deferring validation allows the context to inherit the active setting forignoreUndefinedProperties(defaulting tofalse) instead of forcing it totrueas previously done during construction. The reason it only happens for nested properties is a quirk- probably something that should be fixed.Error message text will report the backend stage naming (
snake_case) rather than the client naming (snakeCase).Previous:
Function addFields called with invalid dataNew:
Function add_fields called with invalid data