File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ def _validate_operation_name(operation_name: str) -> None:
3131 raise HyperbrowserError ("operation_name must be a string" )
3232 if not operation_name .strip ():
3333 raise HyperbrowserError ("operation_name must not be empty" )
34+ if any (
35+ ord (character ) < 32 or ord (character ) == 127 for character in operation_name
36+ ):
37+ raise HyperbrowserError ("operation_name must not contain control characters" )
3438
3539
3640def _validate_retry_config (
Original file line number Diff line number Diff line change @@ -667,6 +667,16 @@ def test_polling_helpers_validate_retry_and_interval_configuration():
667667 retry_delay_seconds = 0 ,
668668 )
669669
670+ with pytest .raises (
671+ HyperbrowserError , match = "operation_name must not contain control characters"
672+ ):
673+ retry_operation (
674+ operation_name = "invalid\n retry" ,
675+ operation = lambda : "ok" ,
676+ max_attempts = 1 ,
677+ retry_delay_seconds = 0 ,
678+ )
679+
670680 with pytest .raises (HyperbrowserError , match = "max_attempts must be an integer" ):
671681 retry_operation (
672682 operation_name = "invalid-retry-type" ,
@@ -804,5 +814,16 @@ async def validate_async_operation_name() -> None:
804814 poll_interval_seconds = 0.1 ,
805815 max_wait_seconds = 1.0 ,
806816 )
817+ with pytest .raises (
818+ HyperbrowserError ,
819+ match = "operation_name must not contain control characters" ,
820+ ):
821+ await poll_until_terminal_status_async (
822+ operation_name = "invalid\t async" ,
823+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
824+ is_terminal_status = lambda value : value == "completed" ,
825+ poll_interval_seconds = 0.1 ,
826+ max_wait_seconds = 1.0 ,
827+ )
807828
808829 asyncio .run (validate_async_operation_name ())
You can’t perform that action at this time.
0 commit comments