-
Notifications
You must be signed in to change notification settings - Fork 347
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
Headers (User-Agent) containing non UTF-8 are not well handled (502 http error) #509
Comments
I believe that error comes from Serde when we try to deserialize the event. The problem might be probably here: Did the real lambda crash too? I would have expected that information to be sanitized before arriving to the runtime 🤔 |
The real lambda does not crash and can receive other requests but returns 502 http errors. I think only a worker thread crashes and the main thread then recovers and continues processing data. Errors are not available at lambda but on elb side. Hopefully I had some monitorings on both and detected 502 surge but had a hard time understanding the root cause of the issue. |
I'm unsure how you could handle this before because the code has not changed in that area very much. When the runtime receives the next event from the Lambda API, it tries to deserialize the response body into the structure that gets passed to your function, with the following code: Here in the current version: And here in one of the early versions: But anyways, you can see the problem reproduced plainly with serde_json and your payload: |
Probably somewhere, target deserialization type changed from byte slice to https://github.com/serde-rs/json/blob/master/src/de.rs#L1571-L1573 I do agree that the payload is somewhat invalid. But instead of deserializing headers into |
Contributions to solve this are very welcome, I did not find a way to fix it myself so far. |
I am also looking at this issue. But it seems serde_json does not like non-utf8 characters at all. The least that can be done is handle the error and send a 400 status error. By the way, I rechecked the old behavior and it seems there were also an issue handling this case but the output was different With the old program I have normal processing of the request:
With new program:
then I need to kill the process to have the console back. |
Actually, the issue is that JSON payload of the ALB is invalid. Should an issue be declared there and find a way to handle these kind of issues |
can you explain this further? |
Then, the JSON produced by AWS infrastructure as an input to the lambda is not valid. I am afraid that the way the input JSON is currently produced, it can not be converted to an If a header name or value contains characters outside of ASCII/UTF-8 characters, a new payload should be created/designed. Otherwise, lambda runtime should be able to detect deserializing issues and respond with a generic Response. (For my case, I could send a |
we're already reporting an error when we cannot deserialize the payload, see #520 |
Nice! Did not see this. I should definitively take time to upgrade to version including this pr. |
I'm closing this ticket because it's not actionable. Serde doesn't handle non UTF-8 characters, and we don't have plans to fix this. |
|
In one of my projects, created ages ago (prior to going async) I could handle the issue by myself:
I could then handle bad headers by simply ignoring them or return a 400 status code.
I should and will upgrade my code to version 0.6.0 but I can check that this is failing still in lambda_runtime even before it is made available for my code.
test.json
Testing the above payload gives the error:
I could check the same behavior on a real lambda instance to which I sent an actual request and not a crafted payload as above.
The text was updated successfully, but these errors were encountered: