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

TypeError: unhashable type: 'list' in collect_datasource_items #62

Closed
mauhiz opened this issue Feb 24, 2023 · 6 comments
Closed

TypeError: unhashable type: 'list' in collect_datasource_items #62

mauhiz opened this issue Feb 24, 2023 · 6 comments

Comments

@mauhiz
Copy link

mauhiz commented Feb 24, 2023

Env

  • Python 3.9 or 3.11
  • Grafana 9.3.1
  • MacOSX

both "explore datasources" and "explore dashboards" command fail:

[grafana_wtf.core      ] INFO   : Found 185 data source(s)
Traceback (most recent call last):
  File "~/grafana_wtf/commands.py", line 237, in run
    results = engine.explore_datasources()
  File "~/grafana_wtf/core.py", line 406, in explore_datasources
    ix = Indexer(engine=self)
  File "~/grafana_wtf/core.py", line 492, in __init__
    self.index()
  File "~/grafana_wtf/core.py", line 496, in index
    self.index_dashboards()
  File "~/grafana_wtf/core.py", line 543, in index_dashboards
    ds_templating = self.collect_datasource_items(dbdetails.templating)
  File "~/grafana_wtf/core.py", line 514, in collect_datasource_items
    datasource = self.datasource_by_name.get(ds_name, {})
TypeError: unhashable type: 'list'

As I see in #44 that 9.3.1 is not officially supported yet, I am assuming it has something to do with Grafana compatibility.
Please let me know if there is something I can do to help more.

@amotl
Copy link
Contributor

amotl commented Feb 24, 2023

Dear Vincent,

thank you for writing in and for reporting this issue.

I am assuming it has something to do with Grafana compatibility.

That's probably true. Apparently, Grafana may have changed some bits within their dashboard structure, which will have to get compensated similar to GH-27 and GH-32.

Maybe you can share a sample of the corresponding datasource or dashboard JSON representations, where you may expect the root cause of this?

On this matter, see also 1, where we maintain a set of dashboard variants through different versions where breaking changes occurred in the past.

As I see in #44 that 9.3.1 is not officially supported yet.

It might not be fully supported yet, because the test suite does not pass completely, but we still should aim for reasonable compatibility, regardless of this specific regression we observed.

With kind regards,
Andreas.

Footnotes

  1. https://github.com/panodata/grafana-wtf/tree/main/tests/grafana/dashboards

@mauhiz
Copy link
Author

mauhiz commented Feb 27, 2023

Hi Andreas, thank for your quick reply.
I will try to minimize a reproducer

@mauhiz
Copy link
Author

mauhiz commented Feb 27, 2023

I'm having trouble isolating the exact issue (and not familiar enough with Python) but I was able to get it to print the state while seeing the invalid input :

node=Munch({'current': Munch({'selected': True, 'text': ['All'], 'value': ['$__all']}), 'hide': 0, 'includeAll': True, 'multi': True, 'name': 'datasource', 'options': [], 'query': 'prometheus', 'queryValue': '', 'refresh': 1, 'regex': '/.*-storage$/', 'skipUrlSync': False, 'type': 'datasource'})

After get("current")

current_node=Munch({'selected': True, 'text': ['All'], 'value': ['$__all']})

After get("value")

ds_name=['$__all']

It seems to be related to defining a template variable that matches the following aspects

  • is queried from a templated datasource
  • has "Include All option"

@amotl
Copy link
Contributor

amotl commented Mar 5, 2023

Dear Vincent,

thanks a stack for providing corresponding debug information. From those details, I can imagine that the problem is related to the recent addition of the feature »Improve discovery of data sources defined by dashboard variables« (GH-60) with version 0.14.0.

Can you try downgrading to version 0.13.4 using pip install grafana-wtf==0.13.4 and report back if that improves the situation for you, until we will come up with a corresponding fix?

With kind regards,
Andreas.

@amotl
Copy link
Contributor

amotl commented Mar 5, 2023

Dear Vincent,

we just released grafana-wtf-0.14.1 with the fix on behalf of GH-63. We will be happy to hear back if that will resolve the problem for you. Thanks again for the excellent report.

With kind regards,
Andreas.

@mauhiz
Copy link
Author

mauhiz commented Mar 6, 2023

Hi Andreas,

Thank you for your excellent and timely support. I confirmed that the problem is solved for me.

@mauhiz mauhiz closed this as completed Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants