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

can't force lambda failure for non http events #537

Open
jordandobrev opened this issue Nov 16, 2024 · 3 comments
Open

can't force lambda failure for non http events #537

jordandobrev opened this issue Nov 16, 2024 · 3 comments

Comments

@jordandobrev
Copy link

Hey guys, I have a trigger setup for kafka events - aws:kafka. When I return any non 200 response back from my \events endpoint it treats the execution as a success. That would prevent the automatic aws retry mechanism to kick in and will result in missed unprocessed messages.

Is there a way to return a response that would result in a lambda failure?

@bnusunny
Copy link
Contributor

bnusunny commented Nov 16, 2024

No, returning non 200 response won't cause the Lambda invoke to fail. You need to throw an exception to crash the runtime.

@jordandobrev
Copy link
Author

jordandobrev commented Nov 16, 2024

That works thanks! However it was not trivial to make it work with some languages like php with laravel for example. Just throwing an exception will be automatically handled in some cases and converted to a 500 http error. Even if you manage to get the php process to throw the exception anyway and kill the process, it's not the one that runs the environment really as you need an http server. The only way to do that was to locate the main parent process id and to do a pkill on it and wait, as if anything is returned before the parent process is killed it might not fail.

Hopefully there will be sth added in the future to simplify the flow via a response header or/and http status code.

@bnusunny
Copy link
Contributor

I got your problem now. We could improve this for non-http event sources.

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

2 participants