1- import uuid
21import json
32import urllib .parse
4- from typing import Any
3+ import uuid
54
65from concurrent .futures import ThreadPoolExecutor
6+ from typing import Any
77
88from openfga_sdk .client .configuration import ClientConfiguration
99from openfga_sdk .client .models .assertion import ClientAssertion
2727from openfga_sdk .client .models .list_objects_request import ClientListObjectsRequest
2828from openfga_sdk .client .models .list_relations_request import ClientListRelationsRequest
2929from openfga_sdk .client .models .list_users_request import ClientListUsersRequest
30+ from openfga_sdk .client .models .raw_response import RawResponse
3031from openfga_sdk .client .models .read_changes_request import ClientReadChangesRequest
3132from openfga_sdk .client .models .tuple import ClientTuple , convert_tuple_keys
3233from openfga_sdk .client .models .write_request import ClientWriteRequest
3536 construct_write_single_response ,
3637)
3738from openfga_sdk .client .models .write_transaction_opts import WriteTransactionOpts
38- from openfga_sdk .client .models .raw_response import RawResponse
3939from openfga_sdk .constants import (
4040 CLIENT_BULK_REQUEST_ID_HEADER ,
4141 CLIENT_MAX_BATCH_SIZE ,
4242 CLIENT_MAX_METHOD_PARALLEL_REQUESTS ,
4343 CLIENT_METHOD_HEADER ,
4444)
4545from openfga_sdk .exceptions import (
46- ApiException ,
4746 AuthenticationError ,
4847 FgaValidationException ,
4948 UnauthorizedException ,
7372from openfga_sdk .models .write_request import WriteRequest
7473from openfga_sdk .sync .api_client import ApiClient
7574from openfga_sdk .sync .open_fga_api import OpenFgaApi
76- from openfga_sdk .validation import is_well_formed_ulid_string
7775from openfga_sdk .sync .rest import RESTResponse
76+ from openfga_sdk .telemetry .attributes import (
77+ TelemetryAttributes ,
78+ )
79+ from openfga_sdk .validation import is_well_formed_ulid_string
7880
7981
8082def _chuck_array (array , max_size ):
@@ -1145,7 +1147,7 @@ def raw_request(
11451147
11461148 resource_path = path
11471149 path_params_dict = dict (path_params ) if path_params else {}
1148-
1150+
11491151 if "{store_id}" in resource_path and "store_id" not in path_params_dict :
11501152 store_id = self .get_store_id ()
11511153 if store_id is None or store_id == "" :
@@ -1154,13 +1156,13 @@ def raw_request(
11541156 "Set store_id in ClientConfiguration, use set_store_id(), or provide it in path_params."
11551157 )
11561158 path_params_dict ["store_id" ] = store_id
1157-
1159+
11581160 for param_name , param_value in path_params_dict .items ():
11591161 placeholder = f"{{{ param_name } }}"
11601162 if placeholder in resource_path :
11611163 encoded_value = urllib .parse .quote (str (param_value ), safe = "" )
11621164 resource_path = resource_path .replace (placeholder , encoded_value )
1163-
1165+
11641166 if "{" in resource_path or "}" in resource_path :
11651167 raise FgaValidationException (
11661168 f"Not all path parameters were provided for path: { path } "
@@ -1205,37 +1207,40 @@ def raw_request(
12051207
12061208 telemetry_attributes = None
12071209 if operation_name :
1208- from openfga_sdk .telemetry .attributes import TelemetryAttribute , TelemetryAttributes
12091210 telemetry_attributes = {
12101211 TelemetryAttributes .fga_client_request_method : operation_name .lower (),
12111212 }
12121213 if self .get_store_id ():
1213- telemetry_attributes [TelemetryAttributes .fga_client_request_store_id ] = self .get_store_id ()
1214-
1215- try :
1216- _ , http_status , http_headers = self ._api_client .call_api (
1217- resource_path = resource_path ,
1218- method = method .upper (),
1219- query_params = query_params_list if query_params_list else None ,
1220- header_params = auth_headers if auth_headers else None ,
1221- body = body_params ,
1222- response_types_map = {},
1223- auth_settings = [],
1224- _return_http_data_only = False ,
1225- _preload_content = True ,
1226- _retry_params = retry_params ,
1227- _oauth2_client = self ._api ._oauth2_client ,
1228- _telemetry_attributes = telemetry_attributes ,
1229- )
1230- except ApiException as e :
1231- raise
1214+ telemetry_attributes [
1215+ TelemetryAttributes .fga_client_request_store_id
1216+ ] = self .get_store_id ()
1217+
1218+ _ , http_status , http_headers = self ._api_client .call_api (
1219+ resource_path = resource_path ,
1220+ method = method .upper (),
1221+ query_params = query_params_list if query_params_list else None ,
1222+ header_params = auth_headers if auth_headers else None ,
1223+ body = body_params ,
1224+ response_types_map = {},
1225+ auth_settings = [],
1226+ _return_http_data_only = False ,
1227+ _preload_content = True ,
1228+ _retry_params = retry_params ,
1229+ _oauth2_client = self ._api ._oauth2_client ,
1230+ _telemetry_attributes = telemetry_attributes ,
1231+ )
12321232
12331233 rest_response : RESTResponse | None = getattr (
12341234 self ._api_client , "last_response" , None
12351235 )
12361236
12371237 if rest_response is None :
1238- raise RuntimeError ("Failed to get response from API client" )
1238+ raise RuntimeError (
1239+ f"Failed to get response from API client for { method .upper ()} "
1240+ f"request to '{ resource_path } '"
1241+ f"{ f' (operation: { operation_name } )' if operation_name else '' } . "
1242+ "This may indicate an internal SDK error, network problem, or client configuration issue."
1243+ )
12391244
12401245 response_body : bytes | str | dict [str , Any ] | None = None
12411246 if rest_response .data is not None :
0 commit comments