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:
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.
Summary
ApiClient.request_sync()is a synchronous convenience wrapper, but it passes the already-computed return value from the synchronousApiClient.request()intoasyncio.run_until_complete(). Any successful non-awaitable response therefore raisesTypeErrorinstead of being returned.The async client needs the event-loop bridge; the sync client does not.
Minimal reproduction
Current result:
Expected result:
{"ok": True}Root cause
The sync and async classes currently share the same implementation:
For
AsyncApiClient,self.request(...)is a coroutine. ForApiClient, it is an ordinary synchronous result.Proposed fix
Have
ApiClient.request_sync()directly returnself.request(...), while leavingAsyncApiClient.request_sync()unchanged. Add a regression covering both typed responses andtype_=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 againstdev.