spectacles icon indicating copy to clipboard operation
spectacles copied to clipboard

Unexpected content validation errors

Open d-swift opened this issue 3 years ago • 5 comments

Hey, content validation is throwing a strange error and not returning any validation issues.

Here is the output:

Connected to Looker version 22.12.63 using Looker API 3.1
Building LookML project hierarchy for project 'myproject' @ f5e776

=================== Validating content based on 250 explores ===================

Warning: Skipping some content because it does not seem to be a Dashboard or a Look.
Warning: Skipping some content because it does not seem to be a Dashboard or a Look.
Warning: Skipping some content because it does not seem to be a Dashboard or a Look.
Warning: Skipping some content because it does not seem to be a Dashboard or a Look.
Completed content validation in 1 minute and 23 seconds.


Encountered unexpected TypeError: "'NoneType' object is not subscriptable"
Full error traceback logged to file.

For support, please create an issue at https://github.com/spectacles-ci/spectacles/issues

Here is the command used:

spectacles content \
  --config-file config.yaml \
  --project myproject \
  --do-not-track \

Here is the traceback:

Traceback (most recent call last):
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 153, in wrapper
    return function(*args, **kwargs)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 307, in main
    run_content(
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/utils.py", line 61, in timed_function
    result = fn(*args, **kwargs)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 783, in run_content
    results = runner.validate_content(
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/runner.py", line 467, in validate_content
    validator.validate(project)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/validators/content.py", line 69, in validate
    errors = self._get_errors_from_result(project, content, content_type)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/validators/content.py", line 147, in _get_errors_from_result
    space=result[content_type]["space"]["name"],
TypeError: 'NoneType' object is not subscriptable

d-swift avatar Aug 25 '22 15:08 d-swift

Hey @d-swift, can you update to the release candidate for the next version of Spectacles and try again?

pip install spectacles==2.3.0rc3

joshtemple avatar Aug 25 '22 15:08 joshtemple

I believe this is a duplicate of #610.

joshtemple avatar Aug 25 '22 15:08 joshtemple

Thanks, I'll try this!

d-swift avatar Aug 25 '22 16:08 d-swift

Gave this a shot - getting a new error now. Here's the log for prosperity:

Authenticating to the Looker as client ID 'yourclientid'
Checking Looker instance release version
Connected to Looker version 22.12.63 using Looker API 4.0
Setting up branch manager in project 'projectname'

Setting Git state for project 'projectname' @ master:
.. Getting the workspace in use by this session
.. Getting active branch for project 'projectname'
.. The active branch is 'master'
.. Updating session to use the dev workspace
.. Setting project 'projectname' branch to 'master'
.. Set project 'projectname' to branch 'master' @ HEAD in dev workspace [ephemeral =
     False]
.. Getting manifest details
.. Project 'projectname' imports the following projects: []
.. Project 'projectname' doesn't import any other projects

Building LookML project hierarchy for project 'projectname' @ master
Getting all models and explores from https://projectname.looker.com

=================== Validating content based on 250 explores ===================

Validating all content in Looker

Cleaning up Git state in 'projectname'
.. Restoring project 'projectname' to branch 'master'
.. Updating session to use the production workspace

Completed content validation in 2 minutes and 30 seconds.

'title'
Traceback (most recent call last):
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 155, in wrapper
    return function(*args, **kwargs)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 315, in main
    asyncio.run(
  File "/opt/homebrew/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/homebrew/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/utils.py", line 60, in timed_function
    result = await fn(*args, **kwargs)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/cli.py", line 817, in run_content
    results = await runner.validate_content(
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/runner.py", line 494, in validate_content
    await validator.validate(project)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/validators/content.py", line 75, in validate
    errors = self._get_errors_from_result(project, content, content_type)
  File "/Users/username/Library/Caches/pypoetry/virtualenvs/lookoverhere-ZKlKpy3y-py3.10/lib/python3.10/site-packages/spectacles/validators/content.py", line 166, in _get_errors_from_result
    title=result[content_type]["title"],
KeyError: 'title'

Encountered unexpected KeyError: "'title'"
Full error traceback logged to file.

For support, please create an issue at https://github.com/spectacles-ci/spectacles/issues

d-swift avatar Aug 25 '22 16:08 d-swift

Thanks @d-swift! Looks like we can't always rely on those content objects having a title. I wish we had better guarantees from the Looker API about this sort of thing, but we don't.

I'll get a fix written for this as soon as possible. If it's something you need sooner, I'd also definitely accept a PR! It should be a quick fix to use .get('title') instead of ['title']

joshtemple avatar Aug 25 '22 19:08 joshtemple

Closing as duplicate.

DylanBaker avatar Jul 17 '23 15:07 DylanBaker