Search code examples
pythonjsonpython-3.xapache-superset

Unable to load dashboards list due to JSON decode error in Apache Superset


I am trying to fetch dashboards in my Superset but I face the following error:

ERROR:root:Expecting ',' delimiter: line 1 column 106 (char 105)

The above error is while I tail the pod.

On front-end, I only see: An error occurred while fetching dashboards.

The complete stacktrace is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/__init__.py", line 84, in wraps
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/__init__.py", line 154, in wraps
    return f(self, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/__init__.py", line 1567, in get_list
    return self.get_list_headless(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/superset/views/base_api.py", line 232, in get_list_headless
    duration, response = time_function(super().get_list_headless, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/superset/utils/core.py", line 1296, in time_function
    response = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/__init__.py", line 1469, in get_list_headless
    _response[API_RESULT_RES_KEY] = _list_model_schema.dump(lst, many=True)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/schema.py", line 557, in dump
    result = self._serialize(processed_obj, many=many)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/schema.py", line 517, in _serialize
    for d in typing.cast(typing.Iterable[_T], obj)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/schema.py", line 517, in <listcomp>
    for d in typing.cast(typing.Iterable[_T], obj)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/schema.py", line 521, in _serialize
    value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/fields.py", line 308, in serialize
    value = self.get_value(obj, attr, accessor=accessor)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/fields.py", line 227, in get_value
    return accessor_func(obj, check_key, default)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/schema.py", line 478, in get_attribute
    return get_value(obj, attr, default)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/utils.py", line 232, in get_value
    return _get_value_for_key(obj, key, default)
  File "/usr/local/lib/python3.6/site-packages/marshmallow/utils.py", line 246, in _get_value_for_key
    return getattr(obj, key, default)
  File "/usr/local/lib/python3.6/site-packages/superset/models/dashboard.py", line 158, in url
    json_metadata = json.loads(self.json_metadata)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 106 (char 105)

I tried to take a look at the dashboards table in my DB but could not find any irregularity. I tried to load the dashboards page(/dashboard/list/) and got the same JSON error as above.

In my db, I tried to mark all dashboards as false under the published column, even the error didn't go away.


Solution

  • Seems like the json_metadata column is broken in either 1 or all of the rows in the dashboards table. I would try to get to the bottom of why it's failing (looks like it's this line). You could try to run a development version of superset against the db and add some logging around where it's failing. You could also try inspecting the json_metadata column in that table (try feeding it to a the python json parser) and see if you can identify the issue causing the json.loads function to fail.