Dealing with Plug.Parsers' fragility

Plug.Parser will raise undo a bunch of conditions that cannot be considered unexpected. I find this problematic because bad user input should be considered the norm. It’s an ops pain because it generates a bunch of errors that aren’t actionable nor particularly easy to filter

As an example, this will crash:

echo -e '\xf0\x28\x8c\xbc' | curl -X POST -H 'Content-Type: application/json' --data-binary @- --url 'http://localhost:5719'

I feel like my options are: 1) write my own parsers, 2) try to filter out the errors in our error ingestion (difficult because this leads to multiple lines being printed) 3) write my own error handling plug that does not re-throw these exceptions

Curious if anyone else is dealing with this?

This is precisely why it works as it does. Alerting the user to invalid input data needs to be reported back to them as quickly as possible, for allowing invalid data to propagate through the system allows it to corrupt all manner of things in horrible horrible ways. It’s not that they are unexpected, it’s that they are errors, and thus reporting them as such.


This does not cause a process crash for me. What version of cowboy / plug are you using?


Is that even a valid start of an HTTP request?

1 Like