1212T = TypeVar ("T" )
1313
1414
15+ def _validate_operation_name (operation_name : str ) -> None :
16+ if not isinstance (operation_name , str ):
17+ raise HyperbrowserError ("operation_name must be a string" )
18+ if not operation_name .strip ():
19+ raise HyperbrowserError ("operation_name must not be empty" )
20+
21+
1522def _validate_retry_config (
1623 * ,
1724 max_attempts : int ,
@@ -71,6 +78,7 @@ def poll_until_terminal_status(
7178 max_wait_seconds : Optional [float ],
7279 max_status_failures : int = 5 ,
7380) -> str :
81+ _validate_operation_name (operation_name )
7482 _validate_poll_interval (poll_interval_seconds )
7583 _validate_max_wait_seconds (max_wait_seconds )
7684 _validate_retry_config (
@@ -111,6 +119,7 @@ def retry_operation(
111119 max_attempts : int ,
112120 retry_delay_seconds : float ,
113121) -> T :
122+ _validate_operation_name (operation_name )
114123 _validate_retry_config (
115124 max_attempts = max_attempts ,
116125 retry_delay_seconds = retry_delay_seconds ,
@@ -137,6 +146,7 @@ async def poll_until_terminal_status_async(
137146 max_wait_seconds : Optional [float ],
138147 max_status_failures : int = 5 ,
139148) -> str :
149+ _validate_operation_name (operation_name )
140150 _validate_poll_interval (poll_interval_seconds )
141151 _validate_max_wait_seconds (max_wait_seconds )
142152 _validate_retry_config (
@@ -177,6 +187,7 @@ async def retry_operation_async(
177187 max_attempts : int ,
178188 retry_delay_seconds : float ,
179189) -> T :
190+ _validate_operation_name (operation_name )
180191 _validate_retry_config (
181192 max_attempts = max_attempts ,
182193 retry_delay_seconds = retry_delay_seconds ,
@@ -205,6 +216,7 @@ def collect_paginated_results(
205216 max_attempts : int ,
206217 retry_delay_seconds : float ,
207218) -> None :
219+ _validate_operation_name (operation_name )
208220 _validate_max_wait_seconds (max_wait_seconds )
209221 _validate_retry_config (
210222 max_attempts = max_attempts ,
@@ -251,6 +263,7 @@ async def collect_paginated_results_async(
251263 max_attempts : int ,
252264 retry_delay_seconds : float ,
253265) -> None :
266+ _validate_operation_name (operation_name )
254267 _validate_max_wait_seconds (max_wait_seconds )
255268 _validate_retry_config (
256269 max_attempts = max_attempts ,
@@ -298,6 +311,7 @@ def wait_for_job_result(
298311 fetch_max_attempts : int ,
299312 fetch_retry_delay_seconds : float ,
300313) -> T :
314+ _validate_operation_name (operation_name )
301315 _validate_retry_config (
302316 max_attempts = fetch_max_attempts ,
303317 retry_delay_seconds = fetch_retry_delay_seconds ,
@@ -333,6 +347,7 @@ async def wait_for_job_result_async(
333347 fetch_max_attempts : int ,
334348 fetch_retry_delay_seconds : float ,
335349) -> T :
350+ _validate_operation_name (operation_name )
336351 _validate_retry_config (
337352 max_attempts = fetch_max_attempts ,
338353 retry_delay_seconds = fetch_retry_delay_seconds ,
0 commit comments