Skip to content
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

[BUG] Can no longer return 304 with empty string as body - get 500 internal server error #3712

Open
kschuetz opened this issue Apr 23, 2024 · 4 comments · May be fixed by #3785
Open

[BUG] Can no longer return 304 with empty string as body - get 500 internal server error #3712

kschuetz opened this issue Apr 23, 2024 · 4 comments · May be fixed by #3785

Comments

@kschuetz
Copy link

Tapir version: 1.10.5

Scala version: 3.3.1

Describe the bug
I have some endpoints in my application whose implementations sometimes return a 304 with an empty string as a body.

I have upgraded tapir recently (from 1.2.13 to 1.10.5), and as of this commit, those endpoints no longer work:
2380053

Whenever the endpoints attempt to return a 304, I get a 500 Internal Server Error instead.

It looks like the cause is this line:
case (StatusCode.NoContent | StatusCode.NotModified, Some(_)) => monad.error(new IllegalStateException(s"Unexpected response body when status code == $statusCode"))

Is there any way to disable this check or get around it? I won't be able to change the API contract of my application.

@kschuetz
Copy link
Author

As a temporary workaround, I made my endpoints return 399 and added an interceptor at the top level to convert 399s to 304s.

@adamw
Copy link
Member

adamw commented Apr 24, 2024

I think it's the same problem as #3682

Since this is problematic, let's simply remove this check.

@kschuetz
Copy link
Author

Appreciate the quick response!

@adamw
Copy link
Member

adamw commented Apr 24, 2024

Still looking for somebody to create the PR, just in case :)

@ShahOdin ShahOdin linked a pull request May 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants