You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
firestore: Query.stream() raises AttributeError: '_UnaryStreamMultiCallable' object has no attribute '_retry' when a stream on the default retry meets a gRPC error (still present in 2.34.1) #19129
When a stream() that was called with the default retry meets a gRPC error part-way through (we see it as a timeout on a throttled instance), Query.stream calls _retry_query_after_exception(exc, retry, transaction). With retry is gapic_v1.method.DEFAULT, that method reads:
transport.run_query is the raw gRPC stub (_UnaryStreamMultiCallable), not the wrapped method, so it has no _retry. The caller gets an AttributeError instead of a retry or the original GoogleAPICallError, so except GoogleAPICallError handlers never see the real error.
retry=None fails the same way, at retry._predicate(exc).
Minimal reproduction (no network)
fromgoogle.api_coreimportexceptions, gapic_v1fromgoogle.auth.credentialsimportAnonymousCredentialsfromgoogle.cloudimportfirestoreclient=firestore.Client(project="p", credentials=AnonymousCredentials())
query=client.collection("x")._query()
query._retry_query_after_exception(exceptions.ServiceUnavailable("x"), gapic_v1.method.DEFAULT, None)
# AttributeError: '_UnaryStreamMultiCallable' object has no attribute '_retry'
Workaround
Pass an explicit Retry to every stream() call, e.g. stream(retry=google.api_core.retry.Retry(predicate=lambda exc: False), timeout=...).
Prior report
The same error was reported in googleapis/python-firestore#596 (2022). That issue was closed in 2023 and then reported again by a commenter in January 2024. The repository is now archived, so I'm filing it here.
Activity