Skip to content

Commit c410dc2

Browse files
committed
livekit-api: a negative list limit leaves the page size to the server
1 parent a1d9f02 commit c410dc2

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎livekit-api/livekit/api/public_api_client.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ async def list(
116116
data = await self._call(
117117
operation=operation,
118118
headers=headers,
119-
params={"page_cursor": page_token, "page_page_size": limit, **params},
119+
# A limit of zero or below leaves the page size to the server.
120+
params={"page_cursor": page_token, "page_page_size": max(limit, 0), **params},
120121
)
121122
next_page = (data.get("pageInfo") or {}).get("nextCursor", "")
122123
return _parse({items: data.get("items"), "nextPageToken": next_page}, response_class)

‎tests/api/test_public_api.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ def test_list_threads_sends_no_unset_filter():
190190
assert len(res.threads) == 0 and res.next_page_token == ""
191191

192192

193+
def test_list_threads_leaves_a_negative_limit_to_the_server():
194+
_, rec = run(lambda lk: lk.threads.list_threads(api.ListThreadsRequest(limit=-1)))
195+
assert rec.query == {}
196+
197+
193198
def test_thread_items():
194199
reply = {
195200
"items": [

0 commit comments

Comments
 (0)