@@ -256,6 +256,48 @@ def strip(self, chars=None): # type: ignore[override]
256256 assert isinstance (exc_info .value .original_error , TypeError )
257257
258258
259+ def test_parse_response_model_wraps_operation_name_empty_check_length_failures ():
260+ class _BrokenOperationName (str ):
261+ class _NormalizedName (str ):
262+ def __len__ (self ):
263+ raise RuntimeError ("operation name length exploded" )
264+
265+ def strip (self , chars = None ): # type: ignore[override]
266+ _ = chars
267+ return self ._NormalizedName ("basic operation" )
268+
269+ with pytest .raises (HyperbrowserError , match = "Failed to normalize operation_name" ) as exc_info :
270+ parse_response_model (
271+ {"success" : True },
272+ model = BasicResponse ,
273+ operation_name = _BrokenOperationName ("basic operation" ),
274+ )
275+
276+ assert isinstance (exc_info .value .original_error , RuntimeError )
277+
278+
279+ def test_parse_response_model_preserves_hyperbrowser_operation_name_empty_check_length_failures ():
280+ class _BrokenOperationName (str ):
281+ class _NormalizedName (str ):
282+ def __len__ (self ):
283+ raise HyperbrowserError ("custom operation name length failure" )
284+
285+ def strip (self , chars = None ): # type: ignore[override]
286+ _ = chars
287+ return self ._NormalizedName ("basic operation" )
288+
289+ with pytest .raises (
290+ HyperbrowserError , match = "custom operation name length failure"
291+ ) as exc_info :
292+ parse_response_model (
293+ {"success" : True },
294+ model = BasicResponse ,
295+ operation_name = _BrokenOperationName ("basic operation" ),
296+ )
297+
298+ assert exc_info .value .original_error is None
299+
300+
259301def test_parse_response_model_truncates_operation_name_in_errors ():
260302 long_operation_name = "basic operation " + ("x" * 200 )
261303
0 commit comments