Skip to content

fix(firestore): BulkWriter pop from an empty deque - #17490

Merged
daniel-sanche merged 3 commits into
mainfrom
firestore_index_error
Jul 27, 2026
Merged

fix(firestore): BulkWriter pop from an empty deque#17490
daniel-sanche merged 3 commits into
mainfrom
firestore_index_error

Conversation

@daniel-sanche

Copy link
Copy Markdown
Contributor

In some situations, the BulkWriter would attempt to pop a retry config from an empty deque. This PR adds a safeguard to end immediately if the list is empty

Fixes #16138

@daniel-sanche
daniel-sanche requested a review from a team as a code owner June 16, 2026 23:50

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 adds a safety check to _schedule_ready_retries in bulk_writer.py to prevent popping from an empty _retries queue. The reviewer suggested a performance improvement to break out of the loop early when the queue is empty, rather than checking the condition on every iteration.

Comment thread packages/google-cloud-firestore/google/cloud/firestore_v1/bulk_writer.py Outdated
…_writer.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 18, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 18, 2026
@daniel-sanche daniel-sanche added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 23, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 23, 2026

@chalmerlowe chalmerlowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a #QUESTION/#NIT.
Leaving it up to your discretion.

Approving regardless.

)

for _ in range(take_until_index):
if not self._retries:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that cover still passes.

#QUESTION
#NIT
Is this conditional something that should be tested to ensure we don't have regression if this code ever changes?

I will approve and defer to you in determining whether adding at test is necessary.

@daniel-sanche
daniel-sanche merged commit 8e826f0 into main Jul 27, 2026
39 checks passed
@daniel-sanche
daniel-sanche deleted the firestore_index_error branch July 27, 2026 16:27
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.

BulkWriter produces IndexError: pop from an empty deque

3 participants