Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Mask JSONDecodeError raised by bad server response data #531

Closed
jyu00 opened this issue Feb 3, 2020 · 2 comments
Closed

Mask JSONDecodeError raised by bad server response data #531

jyu00 opened this issue Feb 3, 2020 · 2 comments
Labels

Comments

@jyu00
Copy link
Collaborator

jyu00 commented Feb 3, 2020

What is the expected behavior?

Occasionally the server would return invalid JSON data. In which case a JSONDecodeError is raised:

  File "/home/travis/build/jyu00/qiskit-ibmq-provider/qiskit/providers/ibmq/api/clients/account.py", line 90, in backend_status
    return self.client_api.backend(backend_name).status()
  File "/home/travis/build/jyu00/qiskit-ibmq-provider/qiskit/providers/ibmq/api/rest/backend.py", line 82, in status
    response = self.session.get(url).json()
  File "/home/travis/virtualenv/python3.8.0/lib/python3.8/site-packages/requests/models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/python/3.8.0/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/python/3.8.0/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/python/3.8.0/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This can be confusing to the user, who might just be doing a normal job.cancel() or backend.status(). We should wrap this with something like RequestsApiError and a message saying invalid data received from the server. Or just retry the request as that usually works.

@jyu00
Copy link
Collaborator Author

jyu00 commented Apr 21, 2020

There is supposedly an API fix coming.

@jyu00 jyu00 removed the on hold Can not fix yet label Apr 30, 2020
@jyu00
Copy link
Collaborator Author

jyu00 commented Aug 31, 2021

This hasn't happened in a while since the server deployed their fix. Closing.

@jyu00 jyu00 closed this as completed Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants