question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Catch ValueError during network discovery for when JSON parsing fails

See original GitHub issue

Observed 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rtibblescommented, Apr 5, 2021

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.

0reactions
jonboisercommented, Sep 8, 2020

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 the requests module.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found