Skip to content

fix(firestore,windows): report unimplemented for sum/average aggregations - #18628

Open
m1roxx wants to merge 1 commit into
firebase:mainfrom
m1roxx:fix/firestore-windows-aggregate-unimplemented
Open

fix(firestore,windows): report unimplemented for sum/average aggregations#18628
m1roxx wants to merge 1 commit into
firebase:mainfrom
m1roxx:fix/firestore-windows-aggregate-unimplemented

Conversation

@m1roxx

@m1roxx m1roxx commented Aug 29, 2026

Copy link
Copy Markdown

Description

On Windows, sum() and average() aggregations are silently unsupported.

The Firebase C++ SDK exposes only Query::Count() — there is no sum or average aggregation in firebase/firestore/aggregate_query.h. The Windows plugin handled that by printing to stdout and moving on:

case AggregateType::kSum:
  std::cout << "Sum is not supported on C++" << std::endl;
  break;

Two user-visible consequences:

  • collection.aggregate(count(), sum('foo')) resolves successfully with the count filled in and getSum('foo') returning null. getSum is typed double?, so this is indistinguishable from a query that legitimately has no sum — the app silently reads wrong data.
  • collection.aggregate(sum('foo')) leaves aggregate_query default constructed, so AggregateQuery::Get() returns FailedFuture (aggregate_query.cc) and the caller gets an opaque error with no indication that the operation is unsupported on this platform.

This PR rejects any aggregation request containing sum() or average() with an explicit unimplemented error, following the precedent set for Windows Storage listing in #18449 ("throw unimplemented instead of returning misleading empty results"). count() is unaffected.

While adding the integration test I found that MethodChannelAggregateQuery.get is the only Firestore method-channel call not wrapped in convertPlatformException, so the error reached callers as a raw PlatformException instead of a FirebaseException. That is fixed here too, the same way MethodChannelQuery.get does it — it also affects Android/iOS, where any aggregate-query failure (for example permission-denied) currently surfaces in the wrong exception type.

Related Issues

No existing issue — found while auditing the Windows plugin. Happy to file one if you'd prefer the report tracked separately.

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

An app that today reads null from getSum() on Windows will now see a FirebaseException. That is the point of the change: the previous value was wrong, not absent.

…ions

The Firebase C++ SDK only implements count() aggregations, so the Windows
plugin printed "Sum is not supported on C++" to stdout and dropped the
aggregation. A mixed request such as `aggregate(count(), sum('foo'))`
therefore resolved successfully with the count filled in and `getSum()`
returning null, which is indistinguishable from a query that legitimately
has no sum. A sum-only request left the AggregateQuery default constructed,
so `Get()` returned a failed future and surfaced an opaque error.

Reject requests containing sum() or average() with an explicit
`unimplemented` error instead, matching how Windows already reports
unsupported Storage list() operations.

`MethodChannelAggregateQuery.get` did not convert platform exceptions, so
the error reached callers as a raw PlatformException rather than a
FirebaseException like every other Firestore API. Wrap it the same way
`MethodChannelQuery.get` does.
@gemini-code-assist

Copy link
Copy Markdown
Contributor
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 the 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 counterproductive. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant