grafana-toolbox / grafana-wtf

Grep through all Grafana entities in the spirit of git-wtf.
GNU Affero General Public License v3.0
143 stars 13 forks source link

[Bug] AttributeError: 'Munch' object has no attribute 'title' #66

Closed atavakoliyext closed 1 year ago

atavakoliyext commented 1 year ago

Version: 0.15.0 Platform: MacOS (installed via homebrew)

Steps to reproduce

Run grafana find alerts

...

Dashboard »...«
=================================

        Title <non-empty>
       Folder General
          UID h...
      Created at 2022-05-19T19:16:28Z by Anonymous 
      Updated at 2023-03-16T20:45:22Z by Anonymous
    Dashboard ...
    Variables ...

Global
------

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/munch/__init__.py", line 103, in __getattr__
    return object.__getattribute__(self, k)
AttributeError: 'Munch' object has no attribute 'title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/munch/__init__.py", line 106, in __getattr__
    return self[k]
KeyError: 'title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/grafana-wtf", line 8, in <module>
    sys.exit(run())
  File "/opt/homebrew/lib/python3.9/site-packages/grafana_wtf/commands.py", line 243, in run
    report.display(options.search_expression, result)
  File "/opt/homebrew/lib/python3.9/site-packages/grafana_wtf/report/textual.py", line 25, in display
    self.output_items("Dashboards", result.dashboards, self.compute_url_dashboard)
  File "/opt/homebrew/lib/python3.9/site-packages/grafana_wtf/report/textual.py", line 90, in output_items
    title = panel.title
  File "/opt/homebrew/lib/python3.9/site-packages/munch/__init__.py", line 108, in __getattr__
    raise AttributeError(k)
AttributeError: title

Notably, this does not happen for every query, which suggests it's triggered by a specific entity being parsed in the response.

amotl commented 1 year ago

Dear Ali,

thanks for your report. grafana-wtf will apparently need to compensate for dashboard representations including panels which are missing title attributes.

With kind regards, Andreas.

atavakoliyext commented 1 year ago

Thank you!

amotl commented 1 year ago

Kudos to @nikodemas!

amotl commented 1 year ago

Just released 0.15.1, including the fix from GH-77. Thank you again.