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

ApiApp throws exception when endpoints return un-JSON-serializable data #184

Closed
robertklep opened this issue Mar 26, 2021 · 3 comments
Closed
Labels

Comments

@robertklep
Copy link

robertklep commented Mar 26, 2021

When an ApiApp instance calls an API endpoint (of another app), and that endpoint returns something that cannot be JSON-serialized (like undefined), an exception is thrown by ApiApp (Error: invalid json response body at Remote Process).

It's not documented anywhere that API endpoints should return data that's JSON-serializable.

@tjallingt tjallingt added the docs label Mar 26, 2021
@tjallingt
Copy link

tjallingt commented Mar 26, 2021

Nice, thanks for reporting!

Do I understand correctly this error happens in the app that performs the call (client), not the one providing the data (server)?
In that case I think we should also print a warning when an api returns data that doesn't json serialize, so the developer of the app in question can spot, and fix, it more easily.

@robertklep
Copy link
Author

Correct, the client gets the exception.

Warning on the server side sounds like a good idea 👍🏻

@tjallingt
Copy link

So actually the issue was that we internally turn undefined into a 204 No Content response but the client tried to parse that as JSON. I added a check so that a 204 status code gets turned back into undefined as expected. I'm going to take a look at the documentation and see if we can explain this behaviour clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants