Skip to content

docs(firestore): document terminal error behavior for iterators#14456

Merged
bhshkh merged 1 commit intogoogleapis:mainfrom
bhshkh:docs/fs-document-iter
Apr 20, 2026
Merged

docs(firestore): document terminal error behavior for iterators#14456
bhshkh merged 1 commit intogoogleapis:mainfrom
bhshkh:docs/fs-document-iter

Conversation

@bhshkh
Copy link
Copy Markdown
Contributor

@bhshkh bhshkh commented Apr 20, 2026

Update the documentation for handwritten iterators to explicitly state that they return the same error indefinitely after an error occurs.

This allows:

  1. Repository Consistency: storage and spanner already behave this way (and storage explicitly documents it). Keeping this behavior in Firestore maintains consistency across the google-cloud-go repository. Changing it only in Firestore would create a special case.
  2. Adherence to Guidelines: The Iterator-Guidelines state that if it's not feasible to continue after an error, it should be documented. Updating the documentation brings Firestore into compliance with this rule.
  3. Avoiding Error Masking: If we change the behavior to return iterator.Done on the second call, we risk masking the error. If a user ignores the error on the first call and calls Next() again, they will get iterator.Done and might assume the iteration completed successfully, processing a partial list of results without realizing an error occurred.

Fixes: #12694
Fixes: #13359

@bhshkh bhshkh requested review from a team as code owners April 20, 2026 04:55
@product-auto-label product-auto-label bot added the api: firestore Issues related to the Firestore API. label Apr 20, 2026
@bhshkh bhshkh enabled auto-merge (squash) April 20, 2026 04:56
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 updates the documentation for several iterator types in the Firestore package to clarify that terminal errors are cached and returned on subsequent calls to Next(). While this behavior is implemented in some iterators like DocumentIterator, the review feedback correctly identifies that CollectionIterator, DocumentSnapshotIterator, and DocumentRefIterator lack the necessary error-caching logic to support these documentation claims, leading to an inconsistency between the code and its description.

Comment thread firestore/docref.go
Comment thread firestore/docref.go
Comment thread firestore/list_documents.go
@bhshkh bhshkh merged commit b7c7bf8 into googleapis:main Apr 20, 2026
11 checks passed
@bhshkh bhshkh deleted the docs/fs-document-iter branch April 20, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API.

Projects

None yet

2 participants