Skip to content

Commit

Permalink
fix handling of ErrorResponseTooLarge
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikschubert committed Feb 13, 2024
1 parent 03a4cf9 commit e9e6d4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions cmd/localstack/custom_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/go-chi/chi"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -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{
Expand All @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion lambda/interop/model.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e9e6d4e

Please sign in to comment.