From e9e6d4eaea04918bd843ebb98a808368e4f773b7 Mon Sep 17 00:00:00 2001 From: Dominik Schubert Date: Tue, 13 Feb 2024 11:20:00 +0100 Subject: [PATCH] fix handling of ErrorResponseTooLarge --- cmd/localstack/custom_interop.go | 7 +++++-- lambda/interop/model.go | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/localstack/custom_interop.go b/cmd/localstack/custom_interop.go index 2bd3541..1941668 100644 --- a/cmd/localstack/custom_interop.go +++ b/cmd/localstack/custom_interop.go @@ -6,6 +6,7 @@ package main import ( "bytes" "encoding/json" + "errors" "fmt" "github.com/go-chi/chi" log "github.com/sirupsen/logrus" @@ -117,8 +118,8 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate interop.Server, logCollecto timeout := int(server.delegate.GetInvokeTimeout().Seconds()) isErr := false if err != nil { - switch err { - case rapidcore.ErrInvokeTimeout: + switch { + case errors.Is(err, rapidcore.ErrInvokeTimeout): log.Debugf("Got invoke timeout") isErr = true errorResponse := ErrorResponse{ @@ -137,6 +138,8 @@ func NewCustomInteropServer(lsOpts *LsOpts, delegate interop.Server, logCollecto if err != nil { log.Fatalln("unable to write to response") } + case errors.Is(err, rapidcore.ErrInvokeDoneFailed): + // we can actually just continue here, error message is sent below default: log.Fatalln(err) } diff --git a/lambda/interop/model.go b/lambda/interop/model.go index a4bdbf4..0a6c45b 100644 --- a/lambda/interop/model.go +++ b/lambda/interop/model.go @@ -1,5 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +// LOCALSTACK CHANGES 2024-02-13: adjust error message for ErrorResponseTooLarge to be in parity with what AWS returns package interop @@ -355,7 +356,7 @@ type ErrorResponseTooLargeDI struct { // ErrorResponseTooLarge is returned when response provided by Runtime does not fit into shared memory buffer func (s *ErrorResponseTooLarge) Error() string { - return fmt.Sprintf("Response payload size (%d bytes) exceeded maximum allowed payload size (%d bytes).", s.ResponseSize, s.MaxResponseSize) + return fmt.Sprintf("Response payload size exceeded maximum allowed payload size (%d bytes).", s.MaxResponseSize) } // AsErrorResponse generates ErrorInvokeResponse from ErrorResponseTooLarge