File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed 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 operation_name != operation_name .strip ():
35+ raise HyperbrowserError (
36+ "operation_name must not contain leading or trailing whitespace"
37+ )
3438 if any (
3539 ord (character ) < 32 or ord (character ) == 127 for character in operation_name
3640 ):
Original file line number Diff line number Diff line change @@ -659,6 +659,17 @@ def test_polling_helpers_validate_retry_and_interval_configuration():
659659 retry_delay_seconds = 0 ,
660660 )
661661
662+ with pytest .raises (
663+ HyperbrowserError ,
664+ match = "operation_name must not contain leading or trailing whitespace" ,
665+ ):
666+ retry_operation (
667+ operation_name = " invalid-retry " ,
668+ operation = lambda : "ok" ,
669+ max_attempts = 1 ,
670+ retry_delay_seconds = 0 ,
671+ )
672+
662673 with pytest .raises (HyperbrowserError , match = "operation_name must be a string" ):
663674 retry_operation (
664675 operation_name = 123 , # type: ignore[arg-type]
@@ -814,6 +825,17 @@ async def validate_async_operation_name() -> None:
814825 poll_interval_seconds = 0.1 ,
815826 max_wait_seconds = 1.0 ,
816827 )
828+ with pytest .raises (
829+ HyperbrowserError ,
830+ match = "operation_name must not contain leading or trailing whitespace" ,
831+ ):
832+ await poll_until_terminal_status_async (
833+ operation_name = " invalid-async " ,
834+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
835+ is_terminal_status = lambda value : value == "completed" ,
836+ poll_interval_seconds = 0.1 ,
837+ max_wait_seconds = 1.0 ,
838+ )
817839 with pytest .raises (
818840 HyperbrowserError ,
819841 match = "operation_name must not contain control characters" ,
You can’t perform that action at this time.
0 commit comments