Enable propogation of fatal errors through io.Reader responses

Open
#504 0 comments 0 reactions 1 assignee View on GitHub

@bmoffatt is already working on this.

Since May 7, 2023.

Assessment

This issue has not been assessed yet.

Description

type/ux

Is your feature request related to a problem? Please describe.

A handler can gracefully force the process to be restarted by returning a messages.InvokeResponse_Error with ShouldExit = true. The usual way this happens is when the function panics, but pass-through is allowed too on the handler's error value https://github.com/aws/aws-lambda-go/blob/caace586bdec3652223cc7761cc8c1c155a85601/lambda/errors.go#L20-L22

However, there's not an equivalent when the response value is a reader.

Describe the solution you'd like

Goal should be able to make this:

type fatalReader struct{}
func (r *fatalReader) Read(_ []byte) (int, error) {
  return 0, messages.InvokeResponse_Error{Type: "IDK", Message: "fatal", ShouldExit: true}
}
func handler() (any, error) {
  return fatalReader{}, nil
}

result in the same logging and error reporting as this:

func hander() (any, error) {
  return nil, messages.InvokeResponse_Error{Type: "IDK", Message: "fatal", ShouldExit: true}
}

Describe alternatives you've considered

Might also expose something like https://github.com/aws/aws-lambda-go/blob/caace586bdec3652223cc7761cc8c1c155a85601/lambda/errors.go#L35-L46 in the public API, to make the construction of these fatal errors easier.

Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
16h 56m
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-lambda-go

All issues in aws/aws-lambda-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.