
The HTTP 500 Solution - zdw
http://www.daemonology.net/blog/2015-11-27-the-HTTP-500-solution.html
======
jack9
> More importantly, attempting to respond to invalid inputs is dangerous, for
> two reasons. First, in such a scenario we've already identified that someone
> is trying to be evil;

Being incorrect is not trying to be evil. smh

> Postel's law states that one should be conservative in what one does, but
> liberal in what one accepts from others; this is great advice for life, but
> terrible advice for writing software

No evidence of that either. I feel like this was written just to be
argumentative; a living example of "Conway's Law".

~~~
cperciva
_Being incorrect is not trying to be evil. smh_

No, not necessarily. But nobody ever _accidentally_ sticks a percent-encoded
NUL byte into a query string.

 _I feel like this was written just to be argumentative_

The main reason was so that I had something to point people at when they
reported such "bugs" to me, actually.

------
philbo

        ...no matter how comprehensive your testing is (and most isn't, since
        there's almost always a bias towards testing things which should suceed
        rather than testing things which should fail) it will never cover as many
        combinations of strange inputs and obscure environments as your code is
        likely to encounter in production. Poorly tested code has more bugs per
        line; and when you're faced with the likelihood of a large number of
        bugs per line of code — whether it's due to poor testing, poor developers,
        or merely because the code is difficult for reviewers to understand — it's
        important to minimize the amount of bug-prone code. The shortest possible
        error-handling path is "exit(1);".
    

This whole section is complete nonsense. Whether you choose to exit(1) or
return 400 Bad Response, you should still write tests that assert you do so
correctly.

The difference between the two options is that clients who receive a 400
response at least know the problem is at their end. Perhaps they can handle it
automatically or perhaps they can flag it to a user or whatever.

Turning everything into a 500 is just a poorly-designed API.

~~~
cperciva
_you should still write tests that assert you do so correctly_

People should do lots of things. I'm talking about a cognitive bias here --
see the 2-4-6 problem.

