Catch ValueError during network discovery for when JSON parsing fails
See original GitHub issueObserved behavior
When trying to import content channels (from local network or internet), no error message is produced even though the connection isn’t established. (The “trying to connect” message stays on forever) This happens when there is a typo in the address. (I used kolibri-demo.learningequality.omg) When there’s no internet, an error message DOES get produced.
Expected behavior
An error message should’ve been produced.
User-facing consequences
The user will not know how long they have to wait to see if the connection is being established.
Errors and logs
…
Steps to reproduce
Import content channels from local network or internet >input “kolibri-demo.learningequality.omg” or something else with a typo in it.
Context
Kolibri version: 0.14.3 Operating system: Android 5.1 Browser: Android App Device: BLU Advance 5.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Displaying better error message than "No JSON object could ...
My JSON file is fine - I'm trying to make my program print useful error messages which are understandable to anybody. Telling them...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >"JSON parsing error: No JSON object could be decoded" or ...
"JSON parsing error: No JSON object could be decoded" or "Lock wait timeout exceeded" errors - with Red Hat Subscription Manager(RHSM) ...
Read more >Demo code: ValueError: syntax error in JSON (after 72 hours ...
I think the issue is that the received json is being truncated — possibly due to a timeout or some other network problem....
Read more >Error messages - Resource Manager - Google Cloud
This document identifies some of the error codes and messages that Google APIs ... For those errors, the value of the domain property...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is that we do catch requests
RequestException
here: https://github.com/learningequality/kolibri/blob/develop/kolibri/core/discovery/utils/network/client.py#L56 but are not catching the JSON Decode Error.We should add
ValueError
to the tuple of caught exceptions, as a Python 2 compatible way of catching the error.I think one way to fix it is to handle more general
Exceptions
at this line.https://github.com/learningequality/kolibri/blob/65c0d60a7b2507337f95b131492e47d0e62e2b47/kolibri/core/discovery/utils/network/client.py#L56-L57
But maybe the problem here is that
.omg
isn’t a real TLD? It might be something internal to therequests
module.