Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected keyword argument 'default' #150

Open
jwoodhouse opened this issue Oct 24, 2024 · 3 comments
Open

Unexpected keyword argument 'default' #150

jwoodhouse opened this issue Oct 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jwoodhouse
Copy link

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

@jwoodhouse jwoodhouse changed the title Unexpected keyword argument 'datasource' Unexpected keyword argument 'default' Oct 25, 2024
@amotl
Copy link
Contributor

amotl commented Oct 31, 2024

Hi @jwoodhouse. Thanks for your excellent report and instructions how to work around the problem. Would you be up for submitting a corresponding patch? We will be happy to converge that improvement into another release right away. Cheers.

@sanadhis
Copy link

Hey @jwoodhouse your workaround above also works for my setting:

  • grafana-wtf v0.20.0
  • grafana (cloud): 11.4.0-79146

Would be happy to see this being patched 😄

@jwoodhouse
Copy link
Author

Glad to hear its helped you as well. I've been a bit busy recently, but I'll dedicate some time this weekend to submit a PR with a patch.

@amotl amotl added the bug Something isn't working label Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants