diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0e6d55d..beae509 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: 1.18 - name: Build run: make compile-lambda-linux-all diff --git a/cmd/localstack/custom_interop.go b/cmd/localstack/custom_interop.go index 7946628..e9ddb42 100644 --- a/cmd/localstack/custom_interop.go +++ b/cmd/localstack/custom_interop.go @@ -100,6 +100,9 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo NeedDebugLogs: true, InvokedFunctionArn: invokeR.InvokedFunctionArn, }) + if err != nil { + log.Fatalln(err) + } inv := GetEnvOrDie("AWS_LAMBDA_FUNCTION_TIMEOUT") timeoutDuration, _ := time.ParseDuration(inv + "s") memorySize := GetEnvOrDie("AWS_LAMBDA_FUNCTION_MEMORY_SIZE") @@ -111,21 +114,23 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate rapidcore.InteropServer, lo // TODO: handle err } - callErr := false - var errR ErrorResponse - err := json.Unmarshal(invokeResp.Body, &errR) - if err == nil { - callErr = true - } else { - log.Error(err) + var errR map[string]any + marshalErr := json.Unmarshal(invokeResp.Body, &errR) + + if marshalErr != nil { + log.Fatalln(marshalErr) } - if callErr { + _, isErr := errR["errorType"] + + if isErr { + log.Infoln("Sending to /error") _, err = http.Post(server.upstreamEndpoint+"/invocations/"+invokeR.InvokeId+"/error", "application/json", bytes.NewReader(invokeResp.Body)) if err != nil { log.Error(err) } } else { + log.Infoln("Sending to /response") _, err = http.Post(server.upstreamEndpoint+"/invocations/"+invokeR.InvokeId+"/response", "application/json", bytes.NewReader(invokeResp.Body)) if err != nil { log.Error(err) diff --git a/cmd/localstack/main.go b/cmd/localstack/main.go index 05b9149..f5c55b9 100644 --- a/cmd/localstack/main.go +++ b/cmd/localstack/main.go @@ -69,7 +69,7 @@ func main() { go sandbox.Create() // start runtime init - go InitHandler(sandbox, "$LATEST", 30) // TODO: replace this with a custom init + go InitHandler(sandbox, GetEnvOrDie("AWS_LAMBDA_FUNCTION_VERSION"), 30) // TODO: replace this with a custom init // TODO: make the tracing server optional // start blocking with the tracing server