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: 'NoneType' object is not subscriptable #327

Closed
tobiasrummelsberger opened this issue Feb 25, 2021 · 3 comments · Fixed by #352 or #576
Closed

TypeError: 'NoneType' object is not subscriptable #327

tobiasrummelsberger opened this issue Feb 25, 2021 · 3 comments · Fixed by #352 or #576
Assignees
Labels
Bug Something isn't working

Comments

@tobiasrummelsberger
Copy link

When running the Content Validation spectacles returns the following error after 10 to 15 seconds:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/spectacles/cli.py", line 152, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/spectacles/cli.py", line 281, in main
    args.exclude_personal,
  File "/usr/local/lib/python3.7/site-packages/spectacles/utils.py", line 51, in timed_function
    result = fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/spectacles/cli.py", line 604, in run_content
    results = runner.validate_content(explores, excludes, incremental, exclude_personal)
  File "/usr/local/lib/python3.7/site-packages/spectacles/runner.py", line 231, in validate_content
    results = validator.validate()
  File "/usr/local/lib/python3.7/site-packages/spectacles/validators/content.py", line 42, in validate
    if content[content_type]["folder"]["id"] in self.personal_folders:
TypeError: 'NoneType' object is not subscriptable
2021-02-25 07:26:18,460 ERROR | 
Encountered unexpected TypeError: "'NoneType' object is not subscriptable"
@joshtemple
Copy link
Collaborator

Hmm... this is tricky to debug. It looks like you're getting a different response from the Looker API than we expected. Are you comfortable modifying the source code to log out more details so we can see what's going on?

Here's how I would do it.

  1. Run pip show spectacles and note the Location path, this is where Spectacles source code is stored on your machine.
  2. Navigate to that path and edit spectacles/validators/content.py
  3. Right before line 42, you're going to want to drop in this code:
# -- start of new logging code
try:
    content_id = content[content_type]["folder"]["id"]
except TypeError:
    logger.info(content)
    raise
# -- end of new code

# If exclude_personal isn't specified, personal_folders list is empty
if content[content_type]["folder"]["id"] in self.personal_folders:
    continue
else:
    self._handle_content_result(content, content_type)

If you re-run, you should see the part of the Looker API response that's causing the error logged out right before it fails. Could you include that in your response?

@joshtemple joshtemple added the Bug Something isn't working label Feb 27, 2021
@joshtemple joshtemple self-assigned this Feb 27, 2021
@tobiasrummelsberger
Copy link
Author

Hi @joshtemple,

The issue was that a deleted dashboard was still connected to a paused alert. Removing this alert solved the problem.

This is the log:

{'look': None, 'dashboard': {'description': None, 'id': 1, 'title': 'Orders Overview', 'space': None, 'folder': None}, 'dashboard_element': {'body_text': None, 'dashboard_id': 1, 'id': 1, 'look_id': None, 'note_display': None, 'note_state': None, 'note_text': None, 'note_text_as_html': None, 'query_id': 26, 'subtitle_text': None, 'title': 'Number of Orders', 'title_hidden': False, 'title_text': None, 'type': 'vis'}, 'dashboard_filter': None, 'scheduled_plan': None, 'alert': {'id': 1, 'lookml_dashboard_id': '1', 'lookml_link_id': None, 'custom_title': None}, 'lookml_dashboard': None, 'lookml_dashboard_element': None, 'errors': [{'message': 'Unknown model "sennder".', 'field_name': None, 'model_name': 'sennder', 'explore_name': None, 'removable': None}], 'id': 764}

@joshtemple
Copy link
Collaborator

Thanks @tobiasrummelsberger! We'll make a fix to account for this type of error.

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
2 participants