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

iterating over the results of a missing macro gives a bad error #1424

Closed
beckjake opened this issue Apr 29, 2019 · 0 comments · Fixed by #1425
Closed

iterating over the results of a missing macro gives a bad error #1424

beckjake opened this issue Apr 29, 2019 · 0 comments · Fixed by #1425
Assignees

Comments

@beckjake
Copy link
Contributor

Issue

Iterating over the results of a missing macro results in an unhelpful error

Issue description

Iterating over the result of a macro that's missing causes dbt to fail during parsing (eek) with a TypeError (double eek).

This is pretty common when users are using macros in an external package that return iterables (like dbt_utils.group_by()) and forget to run dbt deps.

The core problem is that our ParserMacroCapture override for Undefined during parsing has this:

def __call__(self, *args,**kwargs):
    return True

So any missing macros return True during parsing, and you can't iterate over that!

As a workaround, users can intuit that they need to run dbt deps, and then everything will work. But we should really make this error message less awful, and not require a deep understanding of jinja/dbt's internals to figure out what's happening.

Results

What I got:

$ dbt compile
Running with dbt=0.13.0
Encountered an error:
'bool' object is not iterable

What I expected:

Running with dbt=0.13.0
Found 1 models, 0 tests, 1 archives, 0 analyses, 101 macros, 0 operations, 0 seed files, 1 sources

07:50:51 | Concurrency: 2 threads (target='default')
07:50:51 |
Encountered an error:
Runtime Error
  Compilation Error in model x (models/x.sql)
    'missing_macro' is undefined

System information

dbt: Happens on 0.13.0, I assume most earlier versions as well.

OS/Python version agnostic.

Steps to reproduce

$ cat models/x.sql
{% for x in missing_macro() %}
{% endfor %}
$ dbt compile
Running with dbt=0.13.0
Encountered an error:
'bool' object is not iterable
@beckjake beckjake self-assigned this Apr 29, 2019
beckjake added a commit that referenced this issue Apr 30, 2019
…ned-to-calls

Propagate ParserMacroCapture undefineds into the calls (#1424)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant