@@ -157,6 +157,18 @@ protected override Amazon.Lambda.Core.ResponseStreaming.HttpResponseStreamPrelud
157157 /// <param name="lambdaContext"></param>
158158 protected override void MarshallRequest ( InvokeFeatures features , APIGatewayProxyRequest apiGatewayRequest , ILambdaContext lambdaContext )
159159 {
160+ if ( apiGatewayRequest == null )
161+ {
162+ _logger . LogError ( "MarshallRequest: apiGatewayRequest is null" ) ;
163+ throw new ArgumentNullException ( nameof ( apiGatewayRequest ) ) ;
164+ }
165+
166+ _logger . LogDebug ( "MarshallRequest: Path={Path}, HttpMethod={HttpMethod}, Resource={Resource}, RequestContext={HasContext}" ,
167+ apiGatewayRequest . Path ?? "(null)" ,
168+ apiGatewayRequest . HttpMethod ?? "(null)" ,
169+ apiGatewayRequest . Resource ?? "(null)" ,
170+ apiGatewayRequest . RequestContext != null ) ;
171+
160172 {
161173 var authFeatures = ( IHttpAuthenticationFeature ) features ;
162174
@@ -201,7 +213,8 @@ protected override void MarshallRequest(InvokeFeatures features, APIGatewayProxy
201213 var rawQueryString = Utilities . CreateQueryStringParameters (
202214 apiGatewayRequest . QueryStringParameters , apiGatewayRequest . MultiValueQueryStringParameters , true ) ;
203215
204- requestFeatures . RawTarget = apiGatewayRequest . Path + rawQueryString ;
216+ var pathForTarget = apiGatewayRequest . Path ?? "/" ;
217+ requestFeatures . RawTarget = pathForTarget + rawQueryString ;
205218 requestFeatures . QueryString = rawQueryString ;
206219 requestFeatures . Path = path ;
207220
@@ -365,24 +378,24 @@ protected virtual string ParseHttpPath(APIGatewayProxyRequest apiGatewayRequest)
365378 if ( apiGatewayRequest . PathParameters != null && apiGatewayRequest . PathParameters . TryGetValue ( "proxy" , out var proxy ) &&
366379 ! string . IsNullOrEmpty ( apiGatewayRequest . Resource ) )
367380 {
368- var proxyPath = proxy ;
381+ var proxyPath = proxy ?? "" ;
369382 path = apiGatewayRequest . Resource . Replace ( "{proxy+}" , proxyPath ) ;
370383
371384 // Adds all the rest of non greedy parameters in apiGateway.Resource to the path
372385 foreach ( var pathParameter in apiGatewayRequest . PathParameters . Where ( pp => pp . Key != "proxy" ) )
373386 {
374- path = path . Replace ( $ "{{{pathParameter.Key}}}", pathParameter . Value ) ;
387+ path = path . Replace ( $ "{{{pathParameter.Key}}}", pathParameter . Value ?? "" ) ;
375388 }
376389 }
377390
378391 if ( string . IsNullOrEmpty ( path ) )
379392 {
380- path = apiGatewayRequest . Path ;
393+ path = apiGatewayRequest . Path ?? "/" ;
381394 }
382395
383- if ( ! path . StartsWith ( "/" ) )
396+ if ( string . IsNullOrEmpty ( path ) || ! path . StartsWith ( "/" ) )
384397 {
385- path = "/" + path ;
398+ path = "/" + ( path ?? "" ) ;
386399 }
387400 return path ;
388401 }
@@ -394,7 +407,7 @@ protected virtual string ParseHttpPath(APIGatewayProxyRequest apiGatewayRequest)
394407 /// </summary>
395408 protected virtual string ParseHttpMethod ( APIGatewayProxyRequest apiGatewayRequest )
396409 {
397- return apiGatewayRequest . HttpMethod ;
410+ return apiGatewayRequest . HttpMethod ?? "GET" ;
398411 }
399412
400413 /// <summary>
0 commit comments