Skip to content

Commit

Permalink
Improve error message for packages missing dbt_project.yml (#6685)
Browse files Browse the repository at this point in the history
* Improve error message for packages missing `dbt_project.yml`

* Use black formatting

* Update capitalization of expected error message
  • Loading branch information
dbeatty10 authored Jan 20, 2023
1 parent 3aeab73 commit a181cee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230120-112921.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Improve error message for packages missing `dbt_project.yml`
time: 2023-01-20T11:29:21.509967-07:00
custom:
Author: dbeatty10
Issue: "6663"
9 changes: 6 additions & 3 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
{error}
"""

MISSING_DBT_PROJECT_ERROR = """\
No dbt_project.yml found at expected path {path}
Verify that each entry within packages.yml (and their transitive dependencies) contains a file named dbt_project.yml
"""


@runtime_checkable
class IsFQNResource(Protocol):
Expand Down Expand Up @@ -163,9 +168,7 @@ def _raw_project_from(project_root: str) -> Dict[str, Any]:

# get the project.yml contents
if not path_exists(project_yaml_filepath):
raise DbtProjectError(
"no dbt_project.yml found at expected path {}".format(project_yaml_filepath)
)
raise DbtProjectError(MISSING_DBT_PROJECT_ERROR.format(path=project_yaml_filepath))

project_dict = _load_yaml(project_yaml_filepath)

Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def test_no_project(self):
with self.assertRaises(dbt.exceptions.DbtProjectError) as exc:
dbt.config.Project.from_project_root(self.project_dir, renderer)

self.assertIn('no dbt_project.yml', str(exc.exception))
self.assertIn('No dbt_project.yml', str(exc.exception))

def test_invalid_version(self):
self.default_project_data['require-dbt-version'] = 'hello!'
Expand Down

0 comments on commit a181cee

Please sign in to comment.