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

Full-commented-out yaml file contents return ugly error #3568

Closed
jtcohen6 opened this issue Jul 13, 2021 · 3 comments · Fixed by #3630
Closed

Full-commented-out yaml file contents return ugly error #3568

jtcohen6 opened this issue Jul 13, 2021 · 3 comments · Fixed by #3630
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jul 13, 2021

Describe the bug

A user reports seeing this error when trying to parse their project after upgrading to v0.20.0:

Encountered an error:
argument of type 'NoneType' is not iterable

This is the stacktrace:

File "/usr/local/Cellar/dbt/0.20.0_1/libexec/lib/python3.8/site-packages/dbt/parser/schemas.py", line 560, in check_format_version
    if 'version' not in yaml_dct:
TypeError: argument of type 'NoneType' is not iterable

That's very surprising! The error cropping up in this line:
https://github.com/dbt-labs/dbt/blob/f460d275baa4df8cf8713f27e198a3577d6ea71c/core/dbt/parser/schemas.py#L560

Means that yaml_dct must be set to None, somehow. That method is called here:
https://github.com/dbt-labs/dbt/blob/f460d275baa4df8cf8713f27e198a3577d6ea71c/core/dbt/parser/read_files.py#L21-L23

It's pretty hard to imagine yaml_from_file returning None. I've tried a couple different things to trip this error (an empty .yml file, malformed contents, simply the word 'None'), but none (hah) of my attemps has worked. The only way I've managed to reproduce it is by stepping directly into the validate_yaml or yaml_from_file method calls and setting the yaml dictionary to None.

One important hint: The user reports that this project runs fine on earlier versions of dbt. It's only with the upgrade to v0.20.0 that they started seeing this error.

Steps To Reproduce

???

Expected behavior

Definitely not this error!

The output of dbt --version:

/usr/local/Cellar/dbt/0.20.0_1/

(i.e. dbt v0.20.0 installed via Homebrew)

@jtcohen6 jtcohen6 added the bug Something isn't working label Jul 13, 2021
@jtcohen6 jtcohen6 added this to the 0.20.1 milestone Jul 13, 2021
@nathaniel-may
Copy link
Contributor

nathaniel-may commented Jul 14, 2021

I wanted to take a quick peek at this, and drilling all the way down to our call to the yaml loader, we aren't passing along any None values in dbt. Looking at the PyYaml documentation, this line stands out: "If there are no documents in the stream, it returns None." This, of course, is still very odd.

@jtcohen6 jtcohen6 changed the title NoneType yaml file contents in v0.20.0 results in unhelpful error Full-commented-out yaml file contents return ugly error Jul 14, 2021
@jtcohen6
Copy link
Contributor Author

jtcohen6 commented Jul 14, 2021

reproduction case

Create a yaml file that's all comments:

# models/schema.yml
# only comments here

Try parsing the project:

$ dbt --no-partial-parse parse
Running with dbt=0.20.0
14:19:08 | Start parsing.
14:19:08 | Dependencies loaded
14:19:08 | ManifestLoader created
Encountered an error:
argument of type 'NoneType' is not iterable

I think the catch here is, source_file.contents is truthy, but yaml.load() of those contents returns None.

@leahwicz
Copy link
Contributor

@nathaniel-may I'm assigning this to you to look into some more

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
Development

Successfully merging a pull request may close this issue.

3 participants