Skip to content

ApiClient.request_sync rejects successful synchronous responses as non-awaitable #1336

Description

@FU-max-boop

Summary

ApiClient.request_sync() is a synchronous convenience wrapper, but it passes the already-computed return value from the synchronous ApiClient.request() into asyncio.run_until_complete(). Any successful non-awaitable response therefore raises TypeError instead of being returned.

The async client needs the event-loop bridge; the sync client does not.

Minimal reproduction

from unittest.mock import patch

from qdrant_client.http.api_client import ApiClient

client = ApiClient("http://localhost:6333")
with patch.object(client, "request", return_value={"ok": True}):
    client.request_sync(
        type_=dict,
        method="GET",
        url="/collections",
    )

Current result:

TypeError: An asyncio.Future, a coroutine or an awaitable is required

Expected result:

{"ok": True}

Root cause

The sync and async classes currently share the same implementation:

return get_event_loop().run_until_complete(self.request(type_=type_, **kwargs))

For AsyncApiClient, self.request(...) is a coroutine. For ApiClient, it is an ordinary synchronous result.

Proposed fix

Have ApiClient.request_sync() directly return self.request(...), while leaving AsyncApiClient.request_sync() unchanged. Add a regression covering both typed responses and type_=None.

I searched open and closed issues and pull requests for request_sync / ApiClient; I did not find an existing report or implementation. I am preparing a focused patch against dev.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions