From 82795aaeabae86f0c76cb4cf0c50ab9b537d7afb Mon Sep 17 00:00:00 2001 From: Dominik Schubert Date: Wed, 31 May 2023 16:51:06 +0200 Subject: [PATCH 1/2] add logging of exceptions during runtime environment create --- cmd/localstack/custom_interop.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/localstack/custom_interop.go b/cmd/localstack/custom_interop.go index 96966b3..4cddeed 100644 --- a/cmd/localstack/custom_interop.go +++ b/cmd/localstack/custom_interop.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/go-chi/chi" log "github.com/sirupsen/logrus" + "go.amzn.com/lambda/core" "go.amzn.com/lambda/core/statejson" "go.amzn.com/lambda/interop" "go.amzn.com/lambda/rapidcore" @@ -208,11 +209,15 @@ func (c *CustomInteropServer) SendResponse(invokeID string, contentType string, } func (c *CustomInteropServer) SendErrorResponse(invokeID string, response *interop.ErrorResponse) error { - log.Traceln("Function called") - err := c.localStackAdapter.SendStatus(Error, response.Payload) - if err != nil { - return err + is, err := c.InternalState() + rs := is.Runtime.State + if rs.Name == core.RuntimeInitErrorStateName { + err = c.localStackAdapter.SendStatus(Error, response.Payload) + if err != nil { + return err + } } + return c.delegate.SendErrorResponse(invokeID, response) } From 09f5bf688b9b77a090773cdde93f6636b9297271 Mon Sep 17 00:00:00 2001 From: Dominik Schubert Date: Wed, 31 May 2023 16:55:17 +0200 Subject: [PATCH 2/2] add missing error handling --- cmd/localstack/custom_interop.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/localstack/custom_interop.go b/cmd/localstack/custom_interop.go index 4cddeed..7bf3e86 100644 --- a/cmd/localstack/custom_interop.go +++ b/cmd/localstack/custom_interop.go @@ -210,6 +210,9 @@ func (c *CustomInteropServer) SendResponse(invokeID string, contentType string, func (c *CustomInteropServer) SendErrorResponse(invokeID string, response *interop.ErrorResponse) error { is, err := c.InternalState() + if err != nil { + return err + } rs := is.Runtime.State if rs.Name == core.RuntimeInitErrorStateName { err = c.localStackAdapter.SendStatus(Error, response.Payload)