grafana-dashboard requests not properly deserialized

Bug #1876327 reported by Alvaro Uria
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Grafana Charm
Fix Released
Medium
Unassigned

Bug Description

A year ago, the grafana-dashboard interface was implemented, allowing related applications to share dashboards via the charms.reactive Request/Response pattern [1].

When I tested with prometheus-libvirt-exporter "register_dashboard" requests, I got:
"""
Error importing dashboard "libvirt": [{"classification":"DeserializationError","message":"json: cannot unmarshal string into Go value of type models.SaveDashboardCommand"},{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]'
"""

dashboards.new_requests list should have the dash.dashboard attribute checked [2]. If isinstance(dash.dashboard, str), then use json.loads(dash.dashboard):
"""
for dash in dashboards.new_requests:
    dash_obj = dash.dashboard
    if isinstance(dash_obj, str):
        dash_obj = json.loads(dash_obj)
    success, reason = import_dashboard(dash_obj, dash.name)
"""
Note: import_dashboard should return: (True, None)

1. https://charmsreactive.readthedocs.io/en/latest/patterns.html
2. see import_dashboards function on reactive/grafana.py

Related branches

Alvaro Uria (aluria)
Changed in charm-grafana:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Ryan Farrell (whereisrysmind) wrote :

It think we could fix this by further improving the import_dashboard function to handle multiple data types. Check if 'dashboard' is a string, then attempt to convert it into a dictionary with json.loads; if that fails then it can return the its 'success' status and the reason being "cannot convert strng to json"

Logging needs to be implemented in the reactive code for import_dashboards to report the import status and reason, in any case.

Alvaro Uria (aluria)
Changed in charm-grafana:
milestone: none → 20.05
status: Triaged → Fix Committed
Alvaro Uria (aluria)
Changed in charm-grafana:
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.