Skip to content

Unexpected keyword argument 'default' #150

@jwoodhouse

Description

@jwoodhouse

Using both:

grafana-wtf explore datasources and grafana-wtf explore dashboards in our environment causes this to happen:

Traceback (most recent call last):
    File "/home/admin/.local/bin/grafana-wtf", line 8, in <module>
        sys.exit(run())
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/commands.py", line 322, in run
        results = engine.explore_dashboards(with_data_details=options.data_details, queries_only=options.queries_only)
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/core.py", line 482, in explore_dashboards
        ix = Indexer(engine=self)
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/core.py", line 613, in __init__
        self.index()
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/core.py", line 617, in index
        self.index_dashboards()
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/core.py", line 680, in index_dashboards
        item = DatasourceItem.from_payload(item)
    File "/home/admin/.local/lib/python3.10/site-packages/grafana_wtf/model.py", line 177, in from_payload
        return cls(**payload)
TypeError: DatasourceItem.__init__() got an unexpected keyword argument 'default'

Grafana version 10.2.3

Our instance of Grafana has in the thousands of dashboards, so its unfortunately not feasible for me to find the specific one causing this issue, in order to post the JSON structure. This must have been a somewhat recent dashboard addition that caused this, as ~2 weeks ago this was working fine with no grafana-wtf version change.

As a quick fix on my end I was able to update the DatasourceItem class here:

class DatasourceItem:
"""
Represent a datasource reference within a panel, annotation, or templating (variable).
"""
uid: Optional[str] = None
name: Optional[str] = None
type: Optional[str] = None
url: Optional[str] = None

with an extra argument:
default: Optional[str] = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions