Skip to content

fix(firestore): Read user data from pipeline in union stage#9765

Merged
dlarocque merged 3 commits intomainfrom
dl/readud-ppl-union
Mar 26, 2026
Merged

fix(firestore): Read user data from pipeline in union stage#9765
dlarocque merged 3 commits intomainfrom
dl/readud-ppl-union

Conversation

@dlarocque
Copy link
Copy Markdown
Contributor

@dlarocque dlarocque commented Mar 26, 2026

Fixes #9764.

This bug was introduced in 4e99d4b.

Reading user data in a pipeline has been deferred from stage initialization to when execute(pipeline) is called. An inner pipeline in a union stage never had it's user data read after this change.

This fix calls readUserData on the pipeline passed to the union stage when readUserData is called on the outer pipeline.

Fixes #9764.

This bug was introduced in 4e99d4b.

User data has been deferred from stage initialization to pipeline
execution. User data in pipelines passed to a `union()` stage was not
being read. This fix explicitly checks if a union stage was passed a
Pipeline, and calls it's `readUserData` method with the outer pipeline
context.
@dlarocque dlarocque requested review from a team as code owners March 26, 2026 14:17
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 3f5702d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

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

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves a critical bug in Firestore's pipeline functionality, specifically concerning the union() stage. Previously, user data within pipelines passed to a union() stage was not being correctly processed, leading to incomplete or incorrect query results. The fix ensures that all nested pipelines within a union() operation properly read and incorporate user data, thereby restoring the intended behavior and robustness of complex pipeline queries.

Highlights

  • Bug Fix: Addressed a bug where user data was not correctly read from pipelines when used within a union() stage, which was introduced in a previous commit.
  • Implementation Detail: Modified the _readUserData method within the Union stage to explicitly call _readUserData on the other pipeline if it exists, ensuring proper data propagation.
  • Testing: Introduced new integration and lite test cases to specifically validate the correct behavior of pipelines that include user data and union() operations.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
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 addresses GitHub Issue #9764 by modifying the Union stage in the Firestore pipeline to ensure user data is read from both the primary and 'other' pipeline segments. This change is implemented in _readUserData by conditionally calling this.other._readUserData(context). New integration and lite tests have been added to validate this functionality, specifically for pipelines using union and sort operations. A review comment points out a potential inconsistency in the expected results of the new integration test, suggesting that the sorting order for document IDs might be incorrect, specifically regarding the placement of 'book10' relative to 'book1'.

Comment thread packages/firestore/test/integration/api/pipeline.test.ts
@dlarocque
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
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 fixes GitHub Issue #9764 by ensuring user data is read from the pipeline in the Firestore union stage. It updates the Union class to correctly invoke _readUserData on the associated stage and adds corresponding integration and lite tests. Review feedback suggests programmatically generating expected document IDs in the new tests to enhance maintainability and readability.

Comment thread packages/firestore/test/integration/api/pipeline.test.ts
Comment thread packages/firestore/test/lite/pipeline.test.ts
hsubox76
hsubox76 previously approved these changes Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Firestore pipelines union bug in firebase-js-sdk v12.11.0

3 participants