From 06a30f0447382224aae42743e48b022d45e8fab1 Mon Sep 17 00:00:00 2001 From: Kenny Ning Date: Wed, 15 Jul 2020 17:26:12 -0400 Subject: [PATCH 1/4] Add more helpful error message for misconfiguration in profiles.yml --- core/dbt/config/profile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/dbt/config/profile.py b/core/dbt/config/profile.py index b3c145348ca..3da2936fdea 100644 --- a/core/dbt/config/profile.py +++ b/core/dbt/config/profile.py @@ -197,6 +197,11 @@ def _get_profile_data( .format(profile_name, target_name, outputs)) raise DbtProfileError(msg, result_type='invalid_target') profile_data = outputs[target_name] + + if profile_data is None: + msg = (f"{target_name} is misconfigured in your profiles.yml") + raise DbtProfileError(msg, result_type='invalid_target') + return profile_data @classmethod From 1ecd954199a4a76a16666d649ba814b4eb6ba4d8 Mon Sep 17 00:00:00 2001 From: Kenny Ning Date: Thu, 16 Jul 2020 16:08:02 -0400 Subject: [PATCH 2/4] Address review --- core/dbt/config/profile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/dbt/config/profile.py b/core/dbt/config/profile.py index 3da2936fdea..9de4a6b4d71 100644 --- a/core/dbt/config/profile.py +++ b/core/dbt/config/profile.py @@ -198,8 +198,11 @@ def _get_profile_data( raise DbtProfileError(msg, result_type='invalid_target') profile_data = outputs[target_name] - if profile_data is None: - msg = (f"{target_name} is misconfigured in your profiles.yml") + if not isinstance(profile_data, dict): + msg = ( + f"output '{target_name}' of profile '{profile_name}' is " + f"misconfigured in profiles.yml" + ) raise DbtProfileError(msg, result_type='invalid_target') return profile_data From d7f3518a9ad4a3f1c1ef3efb34069503d28fa0e2 Mon Sep 17 00:00:00 2001 From: Kenny Ning Date: Fri, 17 Jul 2020 11:37:02 -0400 Subject: [PATCH 3/4] Add test --- CHANGELOG.md | 2 ++ test/integration/049_dbt_debug_test/test_debug.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45b98820875..ccd4a547cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Features - Added support for Snowflake query tags at the connection and model level ([#1030](https://github.com/fishtown-analytics/dbt/issues/1030), [#2555](https://github.com/fishtown-analytics/dbt/pull/2555/)) - Added option to specify profile when connecting to Redshift via IAM ([#2437](https://github.com/fishtown-analytics/dbt/issues/2437), [#2581](https://github.com/fishtown-analytics/dbt/pull/2581)) +- Add more helpful error message for misconfiguration in profiles.yml ([#2627](https://github.com/fishtown-analytics/dbt/issues/2569)) ### Fixes - Adapter plugins can once again override plugins defined in core ([#2548](https://github.com/fishtown-analytics/dbt/issues/2548), [#2590](https://github.com/fishtown-analytics/dbt/pull/2590)) @@ -13,6 +14,7 @@ Contributors: - [@brunomurino](https://github.com/brunomurino) ([#2437](https://github.com/fishtown-analytics/dbt/pull/2581)) - [@DrMcTaco](https://github.com/DrMcTaco) ([#1030](https://github.com/fishtown-analytics/dbt/issues/1030)),[#2555](https://github.com/fishtown-analytics/dbt/pull/2555/)) +- [@kning](https://github.com/kning) ([#2627](https://github.com/fishtown-analytics/dbt/issues/2569)) ## dbt 0.18.0b1 (June 08, 2020) diff --git a/test/integration/049_dbt_debug_test/test_debug.py b/test/integration/049_dbt_debug_test/test_debug.py index 77c4dfc0993..35eeb5f47a3 100644 --- a/test/integration/049_dbt_debug_test/test_debug.py +++ b/test/integration/049_dbt_debug_test/test_debug.py @@ -41,7 +41,8 @@ def postgres_profile(self): 'pass': 'notmypassword', 'dbname': 'dbt', 'schema': self.unique_schema() - } + }, + 'none_target': None }) return profile @@ -73,6 +74,11 @@ def test_postgres_wronguser(self): self.run_dbt(['debug', '--target', 'wronguser']) self.assertGotValue(re.compile(r'\s+Connection test'), 'ERROR') + @use_profile('postgres') + def test_postgres_empty_target(self): + self.run_dbt(['debug', '--target', 'none_target']) + self.assertGotValue(re.compile(r"\s+output 'none_target'"), 'misconfigured') + class TestDebugProfileVariable(TestDebug): @property From d08a2b8c02746985a4e83e89ff9cf0a2a986a2b6 Mon Sep 17 00:00:00 2001 From: Kenny Ning Date: Fri, 17 Jul 2020 11:49:38 -0400 Subject: [PATCH 4/4] Add PR link to changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ccd4a547cd8..7d65de573a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,15 +6,14 @@ ### Features - Added support for Snowflake query tags at the connection and model level ([#1030](https://github.com/fishtown-analytics/dbt/issues/1030), [#2555](https://github.com/fishtown-analytics/dbt/pull/2555/)) - Added option to specify profile when connecting to Redshift via IAM ([#2437](https://github.com/fishtown-analytics/dbt/issues/2437), [#2581](https://github.com/fishtown-analytics/dbt/pull/2581)) -- Add more helpful error message for misconfiguration in profiles.yml ([#2627](https://github.com/fishtown-analytics/dbt/issues/2569)) - +- Add more helpful error message for misconfiguration in profiles.yml ([#2569](https://github.com/fishtown-analytics/dbt/issues/2569), [#2627](https://github.com/fishtown-analytics/dbt/pull/2627)) ### Fixes - Adapter plugins can once again override plugins defined in core ([#2548](https://github.com/fishtown-analytics/dbt/issues/2548), [#2590](https://github.com/fishtown-analytics/dbt/pull/2590)) Contributors: - [@brunomurino](https://github.com/brunomurino) ([#2437](https://github.com/fishtown-analytics/dbt/pull/2581)) - [@DrMcTaco](https://github.com/DrMcTaco) ([#1030](https://github.com/fishtown-analytics/dbt/issues/1030)),[#2555](https://github.com/fishtown-analytics/dbt/pull/2555/)) -- [@kning](https://github.com/kning) ([#2627](https://github.com/fishtown-analytics/dbt/issues/2569)) +- [@kning](https://github.com/kning) ([#2627](https://github.com/fishtown-analytics/dbt/pull/2627)) ## dbt 0.18.0b1 (June 08, 2020)