Skip to content

Commit

Permalink
Return proper error message when empty profiles.yml is used for dbt p…
Browse files Browse the repository at this point in the history
…roject
  • Loading branch information
sumanau7 authored and Sumanau Sareen committed Apr 5, 2020
1 parent 6a26a5f commit 1a6af7b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
{profiles_file}/profiles.yml
""".format(profiles_file=PROFILES_DIR)

EMPTY_PROFILE_MESSAGE = """
dbt cannot run because profiles.yml is empty for this dbt project.
"""


def read_profile(profiles_dir: str) -> Dict[str, Any]:
path = os.path.join(profiles_dir, 'profiles.yml')
Expand All @@ -52,7 +56,10 @@ def read_profile(profiles_dir: str) -> Dict[str, Any]:
if os.path.isfile(path):
try:
contents = load_file_contents(path, strip=False)
return load_yaml_text(contents)
yaml_content = load_yaml_text(contents)
if not yaml_content:
raise DbtProfileError(EMPTY_PROFILE_MESSAGE)
return yaml_content
except ValidationException as e:
msg = INVALID_PROFILE_MESSAGE.format(error_string=e)
raise ValidationException(msg) from e
Expand Down

0 comments on commit 1a6af7b

Please sign in to comment.