Repository navigation
Firestore client library's limit API not handling limit(0) correctly #7382
Copy link
Copy link
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.library: firestoreIssues transferred from another repositoryIssues transferred from another repository
Description
Activity
- addedapi: firestoreIssues related to the Firestore API.Issues related to the Firestore API.
on Dec 16, 2025 I've opened a tentative PR (#2464) to attempt fixing this. I'm happy to work with maintainers to get it merged or pass it on if someone else would like to take it over. Let me know what you think!
- addedlibrary: firestoreIssues transferred from another repositoryIssues transferred from another repository
on Mar 4, 2026 - added 2 commits that reference this issue
on Apr 20, 2026 @sofisl @cherylEnkidu Hi — I’ve reopened #8076 with more polished commit messages after realising the issue is impacting a project I’m working on more than expected.
I’m hoping to push this fix through — would you be open to taking a look and advising on how best to get this patched?
- added 2 commits that reference this issue
on Apr 22, 2026 @MarkDuckworth @pearigee hey — any thoughts on this bug fix when you get a chance?
- added 2 commits that reference this issue
on May 1, 2026 - added a commit that references this issue
on May 4, 2026 - added a commit that references this issue
on May 5, 2026 - added a commit that references this issue
on May 11, 2026
Metadata
Metadata
Assignees
Labels
api: firestoreIssues related to the Firestore API.Issues related to the Firestore API.library: firestoreIssues transferred from another repositoryIssues transferred from another repository
Please make sure you have searched for information in the following guides.
A screenshot that you have tested with "Try this API".
Not applicable
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
googleapis/nodejs-firestore@e006f02
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
The link includes a regression test that is expected to fail — it demonstrates the current buggy behaviour.
Another way to reproduce this (which is how I originally ran into the issue) is to spin up a local Firestore emulator, write a unit test that inserts several documents, and then query with
limit(0). You’ll see that the result is unexpectedly non-empty.A clear and concise description of what the bug is, and what you expected to happen.
When users of the query library call
limit(0), the client does not actually include the limit in the request protos.A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
This looks like an oversight. Semantically,
limit(0)is a valid query. There’s also validation logic in the limit implementation that explicitly does not rule out 0 as a value:https://github.com/googleapis/nodejs-firestore/blob/a0c74b78a0a5896004126ba827a02f4c8d374fd0/dev/src/reference/query.ts#L475
One could argue that
limit(0)should simply behave as if no limit were applied. However, if that’s the intended behaviour, the validation logic should likely reject 0 values, and the library should warn users about this surprising behaviour when 0 is provided.