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

bug: _update_token_loop broken on async AbstractExpiringTokenCredentials #539

Closed
malik89303 opened this issue Dec 23, 2024 · 0 comments · Fixed by #540
Closed

bug: _update_token_loop broken on async AbstractExpiringTokenCredentials #539

malik89303 opened this issue Dec 23, 2024 · 0 comments · Fixed by #540
Assignees
Labels
bug Something isn't working

Comments

@malik89303
Copy link

Bug Report

YDB Python SDK version:

3.18.10

Environment

Current behavior:

ydb.aio.credentials.AbstractExpiringTokenCredentials provides ability to create async token provider with async auth_metadata

async def auth_metadata(self):
    return [(credentials.YDB_AUTH_TICKET_HEADER, await self.token())]

but update_token_loop expects sync auth_metadata

future: <Task finished name='update_token_loop' coro=<WriterAsyncIOStream._update_token_loop() done, defined at contrib/python/ydb/py3/ydb/_topic_writer/topic_writer_asyncio.py:686> exception=TypeError("'coroutine' object is not iterable")>
Traceback (most recent call last):
  File "contrib/python/ydb/py3/ydb/_topic_writer/topic_writer_asyncio.py", line 689, in _update_token_loop
    await self._update_token(token=self._get_token_function())
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "contrib/python/ydb/py3/ydb/credentials.py", line 42, in get_auth_token
    for header, token in self.auth_metadata():
                         ^^^^^^^^^^^^^^^^^^^^
TypeError: 'coroutine' object is not iterable",

Expected behavior:

_update_token_loop works fine with async auth_metadata

Steps to reproduce:

  1. create async ydb.aio.Driver with credentials instance of class inherited from ydb.aio.credentials.AbstractExpiringTokenCredentials
class SomeCredentialsProvider(ydb.aio.credentials.AbstractExpiringTokenCredentials):
    ...
    async def _make_token_request(self) -> dict[str, int | str]:
        token = await self._do_something()
        return {
            "expires_in": 1234,
            "access_token": token,
        }

  1. create async TopicReader / TopicWriter
  2. wait until _update_token_loop executes

Related code:

Other information:

@malik89303 malik89303 added the bug Something isn't working label Dec 23, 2024
@vgvoleg vgvoleg self-assigned this Dec 23, 2024
@vgvoleg vgvoleg mentioned this issue Dec 23, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants