TypeError: 'NoneType' object is not subscriptable
See original GitHub issueHi experts,
I encountered this message during a run of spectacles. There was an earlier issue that was similar but in a different place. Here is the traceback:
Traceback (most recent call last):
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/cli.py", line 153, in wrapper
return function(*args, **kwargs)
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/cli.py", line 307, in main
run_content(
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/utils.py", line 61, in timed_function
result = fn(*args, **kwargs)
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/cli.py", line 783, in run_content
results = runner.validate_content(
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/runner.py", line 467, in validate_content
validator.validate(project)
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/validators/content.py", line 70, in validate
errors = self._get_errors_from_result(project, content, content_type)
File "/Users/markus.zhang/PycharmProjects/spectest/venv/lib/python3.8/site-packages/spectacles/validators/content.py", line 148, in _get_errors_from_result
space=result[content_type]["space"]["name"],
So I looked at the code, added one line to print the content
and figured out that this item is probably causing the issue:
{'look': None, 'dashboard': {'description': None, 'title': 'Data Monitoring v2.0', 'space': None, 'folder': None, 'id': 1654}, 'dashboard_element': {'body_text': None, 'dashboard_id': 1654, 'id': 17788, 'look_id': None, 'note_display': None, 'note_state': None, 'note_text': None, 'note_text_as_html': None, 'query_id': 1097027, 'subtitle_text': None, 'title': 'CENSORED INTERNAL', 'title_hidden': False, 'title_text': None, 'type': 'vis', 'rich_content_json': None}, 'dashboard_filter': None, 'scheduled_plan': None, 'alert': {'id': 317, 'lookml_dashboard_id': '1654', 'lookml_link_id': None, 'custom_title': 'censored internal title'}, 'lookml_dashboard': None, 'lookml_dashboard_element': None, 'errors': [{'message': 'Unknown explore "gg_ua_game_summary_daily".', 'field_name': None, 'model_name': 'my_model', 'explore_name': 'my_explore', 'removable': None}], 'id': 820}
The space
is None so it’s causing line 148 to throw an error because [“space”] gives a None so it doesn’t have a [“name”] element.
I managed to patch it up by modifying line 148 to:
space=result[content_type]["space"]["name"] if result[content_type]["space"] is not None else None,
However I don’t know how to deploy the patched version in GitHub Action so maybe you can look into it and patch properly? I’m a bad Python programmer so I’m sure there are better ways.
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:9
Top Results From Across the Web
TypeError: 'NoneType' object is not subscriptable
NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return...
Read more >Python Math - TypeError: 'NoneType' object is not subscriptable
The reason that lista gets set to None is because the return value of list.sort() is None ... it does not return a...
Read more >[Solved] TypeError: 'NoneType' Object is Not Subscriptable
The error, NoneType object is not subscriptable, means that you were trying to subscript a NoneType object. This resulted in a type error....
Read more >Python TypeError: 'NoneType' object is not subscriptable
The “TypeError: 'NoneType' object is not subscriptable” error is common if you assign the result of a built-in list method like sort() ,...
Read more >TypeError: 'NoneType' object is not subscriptable in Python
The Python "TypeError: 'NoneType' object is not subscriptable" occurs when we try to access a None value at a specific index. To solve...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @markus-zhang-unity. It looks like you might be running an old version of Spectacles. Could you please run
spectacles --version
to confirm which version you’re using?You should be able to upgrade the version by running
pip install --upgrade spectacles
. I would try doing that and then re-running the command you had the issue with.Ah. Apologies. I was looking at the code for our upcoming release candidate and not that release.
I think there’s an upcoming release that this might have been solved in. Could you please try the release candidate for 2.3.0 by running
pip install spectacles==2.3.0rc2
and run it again?