diff --git a/.changes/unreleased/Fixes-20241024-104938.yaml b/.changes/unreleased/Fixes-20241024-104938.yaml new file mode 100644 index 00000000000..f47d9feb98b --- /dev/null +++ b/.changes/unreleased/Fixes-20241024-104938.yaml @@ -0,0 +1,6 @@ +kind: Fixes +body: Fix bug when referencing deprecated models +time: 2024-10-24T10:49:38.352328-06:00 +custom: + Author: dbeatty10 danlsn + Issue: "10915" diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 493b562bbdc..d5fbef59a6e 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -590,7 +590,7 @@ def check_for_model_deprecations(self): # Get the child_nodes and check for deprecations. child_nodes = self.manifest.child_map[node.unique_id] for child_unique_id in child_nodes: - child_node = self.manifest.nodes[child_unique_id] + child_node = self.manifest.nodes.get(child_unique_id) if not isinstance(child_node, ModelNode): continue if node.is_past_deprecation_date: diff --git a/tests/functional/deprecations/fixtures.py b/tests/functional/deprecations/fixtures.py index d9ae97603db..85f45d78f47 100644 --- a/tests/functional/deprecations/fixtures.py +++ b/tests/functional/deprecations/fixtures.py @@ -30,6 +30,23 @@ email: something@example.com """ + +deprecated_model_exposure_yaml = """ +version: 2 + +models: + - name: model + deprecation_date: 1999-01-01 00:00:00.00+00:00 + +exposures: + - name: simple_exposure + type: dashboard + depends_on: + - ref('model') + owner: + email: something@example.com +""" + # deprecated test config fixtures data_tests_yaml = """ models: diff --git a/tests/functional/deprecations/test_deprecations.py b/tests/functional/deprecations/test_deprecations.py index 95779338d8a..2cb51935da4 100644 --- a/tests/functional/deprecations/test_deprecations.py +++ b/tests/functional/deprecations/test_deprecations.py @@ -7,6 +7,7 @@ from dbt_common.exceptions import EventCompilationError from tests.functional.deprecations.fixtures import ( bad_name_yaml, + deprecated_model_exposure_yaml, models_trivial__model_sql, ) @@ -99,6 +100,18 @@ def test_package_redirect_fail(self, project): assert expected_msg in exc_str +class TestDeprecatedModelExposure: + @pytest.fixture(scope="class") + def models(self): + return { + "model.sql": models_trivial__model_sql, + "exposure.yml": deprecated_model_exposure_yaml, + } + + def test_exposure_with_deprecated_model(self, project): + run_dbt(["parse"]) + + class TestExposureNameDeprecation: @pytest.fixture(scope="class") def models(self):