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

fix: catch jinja typeerrors during render phase #207

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test(jinja): iter none type error
devmessias committed Oct 28, 2024
commit c9b866720b7aa39fbd9113f1eb3dc590659cb96a
17 changes: 17 additions & 0 deletions tests/unit/test_jinja.py
Original file line number Diff line number Diff line change
@@ -467,6 +467,23 @@ def test_type_error(self) -> None:
with self.assertRaises(DbtRuntimeTypeError):
render_template(template, ctx)

def test_type_error_iter_none(self) -> None:
jinja_string = """
{% set mylist = None %}

{% for item in mylist %}

select '{{ item }}' as my_item
{{ 'union all' if not loop.last }}

{% endfor %}
"""
ctx = {"config": self._dummy_config}

template = get_template(jinja_string, ctx)
with self.assertRaises(DbtRuntimeTypeError):
render_template(template, ctx)


bar_block = """{% mytype bar %}
{# a comment