Is it possible to raise an error when content negotiation is invalid?

Hello! I don’t think this is really a bug report, but I spent a few days debugging a 502 error with this body:

upstream connect error or disconnect/reset before headers. reset reason: protocol error

Turns out I had accidentally included an equivalent of jsonBody[Unit] with a status code of NoContent - which obviously doesn’t make sense.

There was no error logs or a response log from Tapir, so it wasn’t until I realised my foolish mistake that I managed to fix it. I wondered if it would be possible to include a log in this situation?

If not, no problem, I just thought it may help others out :smiley:

@gerryfletch Thanks for reporting this. How about failing the response when there’s a 204 NoContent status but also a body included? A proposed PR: Fail when there's a response body with 204 status code by kciesielski · Pull Request #3095 · softwaremill/tapir · GitHub

Looks great, thanks for taking the time to do that :slight_smile: