Skip to content

Commit

Permalink
Add tests for logging jinja2.Undefined objects
Browse files Browse the repository at this point in the history
[CT-2259](#7108) identifies
an issue wherein dbt-core 1.0-1.3 raise errors if a jinja2.Undefined
object is attempted to be logged. This generally happened in the form
of `{{ log(undefined_variable, info=True) }}`. This commit adding this
test exists for two reasons
1. Ensure we don't have a regression in this going forward
2. Exist as a commit to be used for backport fixes for dbt-core 1.0-1.3
  • Loading branch information
QMalcolm committed Apr 12, 2023
1 parent 84389a7 commit 29ed63b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/unit/test_base_context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dbt.context.base import BaseContext
from jinja2.runtime import Undefined


class TestBaseContext:
def test_log_jinja_undefined(self):
# regression test for CT-2259
try:
os.environ["DBT_ENV_SECRET_LOG_TEST"] = "cats_are_cool"
BaseContext.log(msg=Undefined(), info=True)
except Exception as e:
assert False, f"Logging an jinja2.Undefined object raises an exception: {e}"

0 comments on commit 29ed63b

Please sign in to comment.