diff --git a/lambda/invoke_loop.go b/lambda/invoke_loop.go index 0d4397a6..a121773d 100644 --- a/lambda/invoke_loop.go +++ b/lambda/invoke_loop.go @@ -111,7 +111,7 @@ func reportFailure(invoke *invoke, invokeErr *messages.InvokeResponse_Error) err return fmt.Errorf("unexpected error occured when serializing the function error cause for X-Ray: %v", err) } - if err := invoke.xfailure(bytes.NewReader(errorPayload), contentTypeJSON, causeForXRay); err != nil { + if err := invoke.failure(bytes.NewReader(errorPayload), contentTypeJSON, causeForXRay); err != nil { return fmt.Errorf("unexpected error occurred when sending the function error to the API: %v", err) } return nil diff --git a/lambda/runtime_api_client.go b/lambda/runtime_api_client.go index 298323da..158bd6b4 100644 --- a/lambda/runtime_api_client.go +++ b/lambda/runtime_api_client.go @@ -13,8 +13,6 @@ import ( "log" "net/http" "runtime" - - "github.com/aws/aws-lambda-go/lambda/messages" ) const ( @@ -56,12 +54,6 @@ type invoke struct { client *runtimeAPIClient } -type failure struct { - WorkingDirectory string `json:"working_directory"` - Exceptions []messages.InvokeResponse_Error `json:"exceptions"` - Paths []string `json:"paths"` -} - // success sends the response payload for an in-progress invocation. // Notes: // - An invoke is not complete until next() is called again! @@ -75,11 +67,7 @@ func (i *invoke) success(body io.Reader, contentType string) error { // - The execution of the function process continues, and is billed, until next() is called again! // - A Lambda Function continues to be re-used for future invokes even after a failure. // If the error is fatal (panic, unrecoverable state), exit the process immediately after calling failure() -func (i *invoke) failure(body io.Reader, contentType string) error { - return i.xfailure(body, contentType, nil) -} - -func (i *invoke) xfailure(body io.Reader, contentType string, causeForXRay []byte) error { +func (i *invoke) failure(body io.Reader, contentType string, causeForXRay []byte) error { url := i.client.baseURL + i.id + "/error" return i.client.post(url, body, contentType, causeForXRay) } diff --git a/lambda/runtime_api_client_test.go b/lambda/runtime_api_client_test.go index 7ccd47fb..3f41403f 100644 --- a/lambda/runtime_api_client_test.go +++ b/lambda/runtime_api_client_test.go @@ -92,7 +92,7 @@ func TestClientDoneAndError(t *testing.T) { assert.NoError(t, err) }) t.Run(fmt.Sprintf("happy Error with payload[%d]", i), func(t *testing.T) { - err := invoke.failure(bytes.NewReader(payload), contentTypeJSON) + err := invoke.failure(bytes.NewReader(payload), contentTypeJSON, nil) assert.NoError(t, err) }) } @@ -105,7 +105,7 @@ func TestInvalidRequestsForMalformedEndpoint(t *testing.T) { require.Error(t, err) err = (&invoke{client: newRuntimeAPIClient("🚨")}).success(nil, "") require.Error(t, err) - err = (&invoke{client: newRuntimeAPIClient("🚨")}).failure(nil, "") + err = (&invoke{client: newRuntimeAPIClient("🚨")}).failure(nil, "", nil) require.Error(t, err) } @@ -145,7 +145,7 @@ func TestStatusCodes(t *testing.T) { require.NoError(t, err) }) t.Run("failure should not error", func(t *testing.T) { - err := invoke.failure(nil, "") + err := invoke.failure(nil, "", nil) require.NoError(t, err) }) } else { @@ -158,7 +158,7 @@ func TestStatusCodes(t *testing.T) { } }) t.Run("failure should error", func(t *testing.T) { - err := invoke.failure(nil, "") + err := invoke.failure(nil, "", nil) require.Error(t, err) if i != 301 && i != 302 && i != 303 { assert.Contains(t, err.Error(), "unexpected status code")