-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add more helpful error message for misconfiguration in profiles.yml #2627
Add more helpful error message for misconfiguration in profiles.yml #2627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @kning!
I have a minor copy suggestion I'd like to get feedback on from Jeremy, and a suggestion on catching more bad profiles.
Can you also add an integration test? I think the appropriate place is in test/integration/049_debug_test/test_debug.py
.
You can update the postgres profile to add a new entry with "none_target": None
instead of an actual target definition, and then add a new test that runs debug --target none_target
and make sure it says something reasonable.
Finally, please make a CHANGELOG.md update following the existing pattern, so we can give you credit in our next release! Add yourself to the contributors list for the upcoming release, and add a summary under Features
to this PR and the issue. The name of this PR should be a fine summary.
core/dbt/config/profile.py
Outdated
@@ -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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msg = (f"{target_name} is misconfigured in your profiles.yml") | |
msg = ( | |
f"output '{target_name}' of profile '{profile_name}' is " | |
f"misconfigured in profiles.yml" | |
) |
It'd be nice to point it at where the issue is a bit more clearly in large profiles, here's one way we could add the profile name in and show that we're talking about outputs:
values.
@jtcohen6, do you have any other suggestions on the copy?
core/dbt/config/profile.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be good to check if not isinstance(profile_data, dict)
instead - if it's anything but a dict, we know it's misconfigured.
thanks taking a look |
A question on the integration test @beckjake.
I think I'd need to create a separate postgres profile with only an empty target. However, I'm not sure the best way to do this. The way the test is set up it looks like you can only have one postgres profile? |
Really? I think it'd be sufficient to specify the bad target on the command line with |
ready for review now @beckjake |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Thanks for your contribution to dbt, and thanks for the test!
I'll merge this once the test passes. Windows tests might fail because of a config issue, that's fine - this is not OS-specific behavior, and I have a fix for that in a different open PR.
CHANGELOG.md
Outdated
@@ -6,13 +6,15 @@ | |||
### 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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)) |
CHANGELOG.md
Outdated
|
||
### 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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [@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)) |
All looks great, this will release in 0.18.0 🎉 |
thanks @beckjake ! |
resolves #2569
Description
Adds an additional catch for if the supplied target returns no data and returns a more helpful error message.
Checklist
CHANGELOG.md
and added information about my change to the "dbt next" section. <-- not sure if this change warrants a mention quite yet but let me know if you'd like me to add.Further Validation
Additional screenshot of what the new terminal output looks like (tested against the example target referenced in the issue):