Skip to content

Firestore retries auth errors infinitely. #1130

@sjudd

Description

@sjudd

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version:
  • Python version: python --version 3.11
  • pip version: pip --version
  • google-cloud-firestore version: pip show google-cloud-firestore 2.11.0

Steps to reproduce

  1. Don't be authenticated with the CLI
  2. Run a firestore query

I'd expect to see an auth related error message. Instead the firestore client hangs forever because it's retrying an unretriable exception infinitely (?).

This is quite a common occurrence if you develop with scripts that use firestore because the gcloud CLI auth expires once or twice a day.

Code example

db.collection("test").document().get()

Stack trace

^C^CTraceback (most recent call last):
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 170, in error_remapped_callable
    return _StreamingResponseIterator(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 92, in __init__
    self._stored_first_result = next(self._wrapped)
                                ^^^^^^^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/grpc/_channel.py", line 543, in __next__
    return self._next()
           ^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/grpc/_channel.py", line 969, in _next
    raise self
grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "Getting metadata from plugin failed with error: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate."
        debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"Getting metadata from plugin failed with error: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate.", grpc_status:14, created_time:"2025-11-14T08:53:19.543469-08:00"}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
    result = target()
             ^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/timeout.py", line 130, in func_with_timeout
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 174, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: Reauthentication is needed. Please run `gcloud auth application-default login` to reauthenticate.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  <REDACTED>
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/cloud/firestore_v1/document.py", line 402, in get
    response_iter = self._client._firestore_api.batch_get_documents(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/cloud/firestore_v1/services/firestore/client.py", line 1154, in batch_get_documents
    response = rpc(
               ^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/gapic_v1/method.py", line 131, in __call__
    return wrapped_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func
    return retry_target(
           ^^^^^^^^^^^^^
  File "/Users/samueljudd/Library/Caches/pypoetry/virtualenvs/oasis-zYbk3Ww0-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 164, in retry_target
    time.sleep(sleep)
  File "/Users/samueljudd/.pyenv/versions/3.11.9/lib/python3.11/asyncio/runners.py", line 157, in _on_sigint
    raise KeyboardInterrupt()
KeyboardInterrupt

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the googleapis/python-firestore API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions