Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom error response payload #341

Open
SimplyKnownAsG opened this issue Nov 25, 2020 · 1 comment
Open

Custom error response payload #341

SimplyKnownAsG opened this issue Nov 25, 2020 · 1 comment

Comments

@SimplyKnownAsG
Copy link

SimplyKnownAsG commented Nov 25, 2020

Is your feature request related to a problem? Please describe.
I am frustrated (your terminology) that I cannot customize the error response payload in a lambda.

I'm using a transport agnostic API (GraphQL) inside of my Lambda function. Per the GraphQL specification, the response contains {"data": {...stuff}} when all was good, or {"data": {...stuff}, "errors": [... stuff]} when there are errors. return graphqlPayload, nil works great in most scenarios: I can easily grant permissions to those who should have access, they can easily run the function and parse the response, check for errors, etc.

return graphqlPayload, nil does not work well when running a step function. Specifically, I need to implement my own retry loop to check for $.output.Payload.errors. -- Yuk

Describe the solution you'd like
I would like to be able to do something like this:

if returnError {
    return nil, aws-lambda-go/lambda/messages.WrapError(graphqlPayload)
} else {
    return graphqlPayload, nil
}

Describe alternatives you've considered

  • I've considered using API gateway, but that adds a lot of complexity when compared to simply invoking a Lambda where the permissions are very easily controlled/managed through CFT/CDK. Also, I don't think I was able to use API Gateway within a step function. Plus, I think I'd still need to figure out HTTP error codes for something that is supposed to be transport agnostic.
  • I've considered return payload, someError, but the payload is discarded when there is an error.
  • I've considered return nil, someError, but the error I provide is discarded
  • I've considered creating a second lambda function to invoke in step functions. This is what I'll have to do. it makes me sad.

Additional context

Could something like this MWE goplay work? Is there a requirement elsewhere that the payload of an error contain errorMessage and errorType?

@SimplyKnownAsG
Copy link
Author

How does one draw attention / get a response to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant