@@ -4227,3 +4227,39 @@ def handler(session_id: Annotated[str, Cookie()]):
42274227 assert result ["statusCode" ] == 200
42284228 body = json .loads (result ["body" ])
42294229 assert body ["session_id" ] == "lattice_v1_abc"
4230+
4231+
4232+ def test_alb_response_none_body_with_validation (gw_event_alb ):
4233+ # GIVEN an ALBResolver with validation enabled
4234+ app = ALBResolver (enable_validation = True )
4235+
4236+ gw_event_alb ["path" ] = "/no-content"
4237+ gw_event_alb ["httpMethod" ] = "DELETE"
4238+
4239+ # WHEN a handler returns Response with body=None and return type is None
4240+ @app .delete ("/no-content" )
4241+ def handler () -> None :
4242+ return Response (status_code = 204 , body = None )
4243+
4244+ # THEN the response should be 204 with empty body (not 422 validation error)
4245+ result = app (gw_event_alb , {})
4246+ assert result ["statusCode" ] == 204
4247+ assert result ["body" ] == ""
4248+
4249+
4250+ def test_alb_response_typed_none_body_with_validation (gw_event_alb ):
4251+ # GIVEN an ALBResolver with validation enabled
4252+ app = ALBResolver (enable_validation = True )
4253+
4254+ gw_event_alb ["path" ] = "/no-content"
4255+ gw_event_alb ["httpMethod" ] = "DELETE"
4256+
4257+ # WHEN a handler returns Response[None] with body=None
4258+ @app .delete ("/no-content" )
4259+ def handler () -> Response [None ]:
4260+ return Response (status_code = 204 , body = None )
4261+
4262+ # THEN the response should be 204 with empty body (not 422 validation error)
4263+ result = app (gw_event_alb , {})
4264+ assert result ["statusCode" ] == 204
4265+ assert result ["body" ] == ""
0 commit comments