-
Notifications
You must be signed in to change notification settings - Fork 7.3k
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
Kotlin Coroutines + OkHttp + Retrofit throw errors on 204 responses #3595
Comments
This comment has been minimized.
This comment has been minimized.
No news about this issue? |
You might want to take a look at a Retrofit adapter for Either (currently in PR): arrow-kt/arrow#2621
|
Is using arrow-kt/arrow#2621 the only solution for this issue? |
Actually there is an even simpler workaround: change the return type of your API call to
However in this case if you get an error response like 4xx or 5xx then your method won't throw an exception, as described in #3075 (comment) |
Thanks lukaszkalnik, Sadly, I need to perform specific actions in case of 4xx or 5xx responses, so do not throw an exception will be a problem. Currently I am replacing the 204 code with a 200 code using a
|
We had a production incident because of this bug. Sadly we also had to make some manual workarounds. |
What kind of issue is this?
Question. This issue tracker is not the place for questions. If you want to ask how to do
something, or to understand why something isn't working the way you expect it to, use Stack
Overflow. https://stackoverflow.com/questions/tagged/retrofit
Bug report. If you’ve found a bug, spend the time to write a failing test. Bugs with tests
get fixed. Here’s an example: https://gist.github.com/swankjesse/6608b4713ad80988cdc9
Feature Request. Start by telling us what problem you’re trying to solve. Often a solution
already exists! Don’t send pull requests to implement new features without first getting our
support. Sometimes we leave features out on purpose to keep the project small.
Retrofit version: Tested on 2.7.0 and 2.9.0 and getting the same issue.
Expected: No error.
Actual:
Reproduce code:
Other notes:
Tried all solutions in #1554 but no avail because in
retrofit2.OkHttpCall#parseResponse
it is hardcoded to returnnull
body upon receiving 204 or 205 response codes and skipped any response converters that I would have added.This response is promptly sent to
retrofit2.KotlinExtensions
which hardcoded an error case with anull
body.Also checked #2494 but the reporter was not using Kotlin
Update: May be related to #3075
The text was updated successfully, but these errors were encountered: