Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async Application Default Credentials throws coroutine AttributeError in Cloud Run #1594

Open
autumnjolitz opened this issue Sep 16, 2024 · 0 comments

Comments

@autumnjolitz
Copy link

autumnjolitz commented Sep 16, 2024

Environment details

  • OS: Linux 55851a4b560d 6.10.0-linuxkit #1 SMP PREEMPT_DYNAMIC Wed Jul 17 10:54:05 UTC 2024 x86_64 Linux
  • Python version: 3.12.4
  • pip version: 24.0
  • google-auth version: 2.32.0

Steps to reproduce

from google.auth._default_async import default_async
from google.auth.transport import _aiohttp_requests as aiohttp_requests

async def get_credentials():
    creds, project_id = default_async()
    await creds.refresh(aiohttp_requests.Request())   # <- Kaboom
    return creds, project_id

if __name__ == "__main__":
    import asyncio
    asyncio.run(get_credentials())

Here's a stack trace from one of our apps:

[2024-09-16 18:08:11,366] [mjolnir.app] [424] [ERROR] !!! FATAL !!! Unable to determine cloud run service url!
2024-09-16 11:08:11.372 PDT
Traceback (most recent call last):
    File "/usr/local/lib/python3.12/site-packages/mjolnir/app.py", line 2001, in register_gcp_service_url service_url = await get_cloud_run_service_url()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/cloudops/utils.py", line 459, in get_cloud_run_service_url
    await creds.refresh(aiohttp_requests.Request())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/credentials.py", line 126, in refresh
    self._retrieve_info(request)
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/credentials.py", line 99, in _retrieve_info
    info = _metadata.get_service_account_info(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/_metadata.py", line 318, in get_service_account_info
    return get(request, path, params={"recursive": "true"})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/google/auth/compute_engine/_metadata.py", line 222, in get
content = _helpers.from_bytes(response.data)
                              ^^^^^^^^^^^^^
AttributeError: 'coroutine' object has no attribute 'data'
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

No branches or pull requests

1 participant