diff --git a/config/clients/python/template/src/client/client.py.mustache b/config/clients/python/template/src/client/client.py.mustache index faedf31f..9b569f5d 100644 --- a/config/clients/python/template/src/client/client.py.mustache +++ b/config/clients/python/template/src/client/client.py.mustache @@ -643,17 +643,17 @@ class OpenFgaClient: elif isinstance(options["max_batch_size"], int): max_batch_size = options["max_batch_size"] - check_to_id: dict[str, ClientBatchCheckItem]= {} + id_to_check: dict[str, ClientBatchCheckItem]= {} def track_and_transform(checks): transformed = [] for check in checks: if check.correlation_id is None: check.correlation_id = str(uuid.uuid4()) - if check.correlation_id in check_to_id: - raise FgaValidationException("Duplicate correlation_id provided") + if check.correlation_id in id_to_check: + raise FgaValidationException(f"Duplicate correlation_id ({check.correlation_id}) provided") - check_to_id[check.correlation_id] = check + id_to_check[check.correlation_id] = check transformed.append(construct_batch_item(check)) return transformed @@ -666,7 +666,7 @@ class OpenFgaClient: result = [] sem = asyncio.Semaphore(max_parallel_requests) def map_response(id, result): - check = check_to_id[id] + check = id_to_check[id] return ClientBatchCheckSingleResponse( allowed=result.allowed, request=check, diff --git a/config/clients/python/template/src/sync/client/client.py.mustache b/config/clients/python/template/src/sync/client/client.py.mustache index 5436f24d..a96a321e 100644 --- a/config/clients/python/template/src/sync/client/client.py.mustache +++ b/config/clients/python/template/src/sync/client/client.py.mustache @@ -615,7 +615,7 @@ class OpenFgaClient: elif isinstance(options["max_batch_size"], int): max_batch_size = options["max_batch_size"] - check_to_id: dict[str, ClientBatchCheckItem] = {} + id_to_check: dict[str, ClientBatchCheckItem] = {} def track_and_transform(checks): transformed = [] @@ -623,10 +623,10 @@ class OpenFgaClient: if check.correlation_id is None: check.correlation_id = str(uuid.uuid4()) - if check.correlation_id in check_to_id: - raise FgaValidationException("Duplicate correlation_id provided") + if check.correlation_id in id_to_check: + raise FgaValidationException(f"Duplicate correlation_id ({check.correlation_id}) provided") - check_to_id[check.correlation_id] = check + id_to_check[check.correlation_id] = check transformed.append(construct_batch_item(check)) return transformed @@ -639,7 +639,7 @@ class OpenFgaClient: ] def map_response(id, result): - check = check_to_id[id] + check = id_to_check[id] return ClientBatchCheckSingleResponse( allowed=result.allowed, request=check, diff --git a/config/clients/python/template/test/client/client_test.py.mustache b/config/clients/python/template/test/client/client_test.py.mustache index bcdaacd4..06c8d56f 100644 --- a/config/clients/python/template/test/client/client_test.py.mustache +++ b/config/clients/python/template/test/client/client_test.py.mustache @@ -1902,7 +1902,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): "result": { "fake-uuid": { "error": { - "inputError": "validation_error", + "input_error": "validation_error", "message": "type 'doc' not found" } } @@ -2046,11 +2046,15 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): configuration = self.configuration configuration.store_id = store_id async with OpenFgaClient(configuration) as api_client: - with self.assertRaises(FgaValidationException): + with self.assertRaises(FgaValidationException) as error: await api_client.batch_check( body=body, options={"authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1"}, ) + self.assertEqual( + "Duplicate correlation_id (1) provided", + str(error.exception) + ) await api_client.close() @patch.object(rest.RESTClientObject, "request") diff --git a/config/clients/python/template/test/sync/client/client_test.py.mustache b/config/clients/python/template/test/sync/client/client_test.py.mustache index b012b17b..9d6e934a 100644 --- a/config/clients/python/template/test/sync/client/client_test.py.mustache +++ b/config/clients/python/template/test/sync/client/client_test.py.mustache @@ -1954,7 +1954,7 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): "result": { "fake-uuid": { "error": { - "inputError": "validation_error", + "input_error": "validation_error", "message": "type 'doc' not found" } } @@ -2092,11 +2092,15 @@ class TestOpenFgaClient(IsolatedAsyncioTestCase): configuration = self.configuration configuration.store_id = store_id with OpenFgaClient(configuration) as api_client: - with self.assertRaises(FgaValidationException): + with self.assertRaises(FgaValidationException) as error: api_client.batch_check( body=body, options={"authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1"}, ) + self.assertEqual( + "Duplicate correlation_id (1) provided", + str(error.exception) + ) api_client.close() @patch.object(rest.RESTClientObject, "request")