File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1111)
1212
1313T = TypeVar ("T" )
14+ _MAX_OPERATION_NAME_LENGTH = 200
1415
1516
1617def _validate_non_negative_real (value : float , * , field_name : str ) -> None :
@@ -35,6 +36,10 @@ def _validate_operation_name(operation_name: str) -> None:
3536 raise HyperbrowserError (
3637 "operation_name must not contain leading or trailing whitespace"
3738 )
39+ if len (operation_name ) > _MAX_OPERATION_NAME_LENGTH :
40+ raise HyperbrowserError (
41+ f"operation_name must be { _MAX_OPERATION_NAME_LENGTH } characters or fewer"
42+ )
3843 if any (
3944 ord (character ) < 32 or ord (character ) == 127 for character in operation_name
4045 ):
Original file line number Diff line number Diff line change @@ -688,6 +688,16 @@ def test_polling_helpers_validate_retry_and_interval_configuration():
688688 retry_delay_seconds = 0 ,
689689 )
690690
691+ with pytest .raises (
692+ HyperbrowserError , match = "operation_name must be 200 characters or fewer"
693+ ):
694+ retry_operation (
695+ operation_name = "x" * 201 ,
696+ operation = lambda : "ok" ,
697+ max_attempts = 1 ,
698+ retry_delay_seconds = 0 ,
699+ )
700+
691701 with pytest .raises (HyperbrowserError , match = "max_attempts must be an integer" ):
692702 retry_operation (
693703 operation_name = "invalid-retry-type" ,
@@ -847,5 +857,15 @@ async def validate_async_operation_name() -> None:
847857 poll_interval_seconds = 0.1 ,
848858 max_wait_seconds = 1.0 ,
849859 )
860+ with pytest .raises (
861+ HyperbrowserError , match = "operation_name must be 200 characters or fewer"
862+ ):
863+ await poll_until_terminal_status_async (
864+ operation_name = "x" * 201 ,
865+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
866+ is_terminal_status = lambda value : value == "completed" ,
867+ poll_interval_seconds = 0.1 ,
868+ max_wait_seconds = 1.0 ,
869+ )
850870
851871 asyncio .run (validate_async_operation_name ())
You can’t perform that action at this time.
0 commit comments