From a118952bd670e35bf593613c2d83c8b4996e98b7 Mon Sep 17 00:00:00 2001 From: Evan Sims Date: Thu, 19 Sep 2024 22:54:21 -0500 Subject: [PATCH] fix: ensure `max_parallel_requests` is an `int` value in `batch_check` --- openfga_sdk/client/client.py | 10 ++++++++-- openfga_sdk/sync/client/client.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index 466656b..7458521 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -612,7 +612,7 @@ async def _single_batch_check( semaphore.release() async def batch_check( - self, body: list[ClientCheckRequest], options: dict[str, str] = None + self, body: list[ClientCheckRequest], options: dict[str, str | int] = None ): """ Run a set of checks @@ -631,7 +631,13 @@ async def batch_check( max_parallel_requests = 10 if options is not None and "max_parallel_requests" in options: - max_parallel_requests = options["max_parallel_requests"] + if ( + isinstance(options["max_parallel_requests"], str) + and options["max_parallel_requests"].isdigit() + ): + max_parallel_requests = int(options["max_parallel_requests"]) + elif isinstance(options["max_parallel_requests"], int): + max_parallel_requests = options["max_parallel_requests"] sem = asyncio.Semaphore(max_parallel_requests) batch_check_coros = [ diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index 27bb4a7..54ce067 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -599,7 +599,7 @@ def _single_batch_check( ) def batch_check( - self, body: list[ClientCheckRequest], options: dict[str, str] = None + self, body: list[ClientCheckRequest], options: dict[str, str | int] = None ): """ Run a set of checks @@ -619,7 +619,13 @@ def batch_check( max_parallel_requests = 10 if options is not None and "max_parallel_requests" in options: - max_parallel_requests = options["max_parallel_requests"] + if ( + isinstance(options["max_parallel_requests"], str) + and options["max_parallel_requests"].isdigit() + ): + max_parallel_requests = int(options["max_parallel_requests"]) + elif isinstance(options["max_parallel_requests"], int): + max_parallel_requests = options["max_parallel_requests"] batch_check_response = []