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

**URL:** <https://softwaremill.community/t/is-it-possible-to-raise-an-error-when-content-negotiation-is-invalid/261>\
**Category:** tapir\
**Created:** [July 31, 2023, 9:33am UTC](https://softwaremill.community/t/is-it-possible-to-raise-an-error-when-content-negotiation-is-invalid/261 "2023-07-31T09:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerryfletch](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/gerryfletch/32/102_2.png) [@gerryfletch](https://softwaremill.community/u/gerryfletch)\
**Post date:** [July 31, 2023, 9:33am UTC](https://softwaremill.community/t/is-it-possible-to-raise-an-error-when-content-negotiation-is-invalid/261/1 "2023-07-31T09:33:26Z")

</div>

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

```auto
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 😃

---

<div class="post-metadata">

**Author:** ![kciesielski](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/kciesielski/32/133_2.png) [@kciesielski](https://softwaremill.community/u/kciesielski)\
**Post date:** [August 7, 2023, 10:12am UTC](https://softwaremill.community/t/is-it-possible-to-raise-an-error-when-content-negotiation-is-invalid/261/2 "2023-08-07T10:12:09Z")

</div>

@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](https://github.com/softwaremill/tapir/pull/3095)

---

<div class="post-metadata">

**Author:** ![gerryfletch](https://dub1.discourse-cdn.com/flex005/user_avatar/softwaremill.community/gerryfletch/32/102_2.png) [@gerryfletch](https://softwaremill.community/u/gerryfletch)\
**Post date:** [August 7, 2023, 1:05pm UTC](https://softwaremill.community/t/is-it-possible-to-raise-an-error-when-content-negotiation-is-invalid/261/3 "2023-08-07T13:05:07Z")

</div>

Looks great, thanks for taking the time to do that 🙂
