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

Problem with fetching not a json features #161

Open
melniqw opened this issue Dec 17, 2024 · 7 comments
Open

Problem with fetching not a json features #161

melniqw opened this issue Dec 17, 2024 · 7 comments

Comments

@melniqw
Copy link

melniqw commented Dec 17, 2024

Clipboard - 17 декабря 2024 г , 18_51

We have faced a problem in the lib code caused by the marked string. If the features receive not a json string (for some reason) we fallback to crash right after initialization.

@Bohdan-Kim
Copy link
Collaborator

Not a json features but what the features?
My feature type was String and it was fetched successfully

@melniqw
Copy link
Author

melniqw commented Dec 17, 2024

Yeah I just figured out one more thing, it gets crashed even if we got 500.
Because onSuccess is still being called after error, so check does not stop the block actually.
Снимок экрана 2024-12-17 в 16 05 12
And the features request was a second step of getting malformed answer.

About the features response: still there is a possibility to get something unexpected even with 200 code, so handling the possibility of bad json when decoding is still a good practice imo

@Bohdan-Kim
Copy link
Collaborator

It should be checked.
Do you have ability to use NetworkDispatcher based on Ktor instead of OkHttp?

@melniqw
Copy link
Author

melniqw commented Dec 17, 2024

I came to a solution to write my custom NetworkDispatcher with the fixes in consumeGETRequest and consumePOSTRequest methods:
Снимок экрана 2024-12-18 в 02 31 19

@Bohdan-Kim
Copy link
Collaborator

Great!

@Bohdan-Kim
Copy link
Collaborator

Yeah I just figured out one more thing, it gets crashed even if we got 500. Because onSuccess is still being called after error, so check does not stop the block actually. Снимок экрана 2024-12-17 в 16 05 12 And the features request was a second step of getting malformed answer.

About the features response: still there is a possibility to get something unexpected even with 200 code, so handling the possibility of bad json when decoding is still a good practice imo

It is screenshot from OkHttpDispatcher v1.0.0; v1.0.2 is available on MavenCentral

@vazarkevych
Copy link
Collaborator

vazarkevych commented Jan 13, 2025

Hi, @melniqw. Have you tried increasing the version? If that resolves the issue, please close the it.

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

No branches or pull requests

3 participants