qabro fails to launch and throws `json.decoder.JSONDecodeError` exception

Bug #1887903 reported by Pierre Equoy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bugit
Fix Released
High
Pierre Equoy

Bug Description

Summary
=======

Happens with both QABro 0.12 and 0.13.

Tested on a device with an Intel Atom CPU and 2GB RAM.

Sometimes, qabro fails to launch and throws `json.decoder.JSONDecodeError` exception:

$ qabro
Traceback (most recent call last):
  File "/snap/qabro/119/bin/qabro", line 33, in <module>
    sys.exit(load_entry_point('qabro==0.13', 'console_scripts', 'qabro')())
  File "/snap/qabro/119/lib/python3.6/site-packages/qabro/__init__.py", line 25, in main
    qabro_snap_info = [e for e in ss.get_snaps() if e['name'] == 'qabro'][0]
  File "/snap/qabro/119/lib/python3.6/site-packages/qabro/utils.py", line 54, in get_snaps
    json_resp = self.request(req)
  File "/snap/qabro/119/lib/python3.6/site-packages/qabro/utils.py", line 44, in request
    json_resp = self._get_json_response(raw_resp)
  File "/snap/qabro/119/lib/python3.6/site-packages/qabro/utils.py", line 36, in _get_json_response
    return json.loads(response[begin:end])
  File "/snap/qabro/119/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/snap/qabro/119/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/snap/qabro/119/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Sometimes, qabro can be launched without a problem.

Failure rate: 2/10

Initial investigation
=====================

qabro.utils.snapdsocket.request() seems to not get any raw response from time to time (raw_resp == ''), which leads to the json.decoder.JSONDecodeError exception seen above.

Related branches

Revision history for this message
Pierre Equoy (pieq) wrote :

A better solution to communicate with snapd would be to use, as explained by jamesh on the snapcraft forum a long time ago[1].

It requires python3-gi and gir1.2-snapd-1 packages.

Then (see Snapd Gi doc for more info[2]):

import gi
gi.require_version('Snapd', '1')
from gi.repository import Snapd
c = Snapd.Client()
active_snaps_flag = Snapd.GetSnapsFlags(0)
for snap in c.get_snaps_sync(Snapd.GetSnapsFlags(0), None):
    print(snap.props.name, snap.props.devmode)

[1] https://forum.snapcraft.io/t/how-to-communicate-with-run-snapd-socket-using-python/6432/4
[2] https://lazka.github.io/pgi-docs/#Snapd-1

Pierre Equoy (pieq)
Changed in qabro:
importance: Undecided → High
status: New → Fix Committed
Pierre Equoy (pieq)
Changed in qabro:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.