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

JSONDecodeError upon empty response body #48

Open
ariel-m-s opened this issue Apr 7, 2021 · 3 comments
Open

JSONDecodeError upon empty response body #48

ariel-m-s opened this issue Apr 7, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@ariel-m-s
Copy link
Contributor

ariel-m-s commented Apr 7, 2021

A JSONDecodeError (from the built-in json library) is raised for HTTP responses with an empty body (which is, naturally, not a JSON). I don’t think this is the expected behavior.

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I guess the expected behavior should be to return an empty string.

@daleal daleal added the bug Something isn't working label Apr 7, 2021
@daleal
Copy link
Owner

daleal commented Apr 8, 2021

Yes, that is definitely not the expected behavior. I think that maybe if the request body doesn't exist (and the text property is empty), Zum should show the response code of the request. Or maybe showing nothing is the right behavior. In any case, the CLI shouldn't fail on no body.

@ariel-m-s
Copy link
Contributor Author

Would it be better to add a condition (if response.text) o just try to parse is as JSON and catch the exception?

@daleal
Copy link
Owner

daleal commented Apr 9, 2021

I think that a combination may be the correct way to handle it. Some response.text might not be JSON-valid but still contain text. In that case, the text should be shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants