Skip to content

Commit

Permalink
Merge pull request #1551 from fishtown-analytics/fix/package-without-…
Browse files Browse the repository at this point in the history
…version

require versions in package defs (#1546)
  • Loading branch information
beckjake authored Jun 18, 2019
2 parents 85164b6 + 927c374 commit f95c712
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/dbt/contracts/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class Project(APIObject):
'description': 'The version of the package',
},
},
'required': ['package'],
'required': ['package', 'version'],
}


Expand Down
5 changes: 5 additions & 0 deletions core/dbt/task/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class RegistryPackage(Package):
SCHEMA = REGISTRY_PACKAGE_CONTRACT

def __init__(self, *args, **kwargs):
if 'version' not in kwargs:
dbt.exceptions.raise_dependency_error(
'package dependency {} is missing a "version" field'
.format(kwargs.get('package'))
)
super(RegistryPackage, self).__init__(*args, **kwargs)
self._version = self._sanitize_version(self._contents['version'])

Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_init(self):
self.assertEqual(a.source_type(), 'hub')

def test_invalid(self):
with self.assertRaises(dbt.exceptions.ValidationException):
with self.assertRaises(dbt.exceptions.DependencyException):
RegistryPackage(package='namespace/name', key='invalid')

def test_resolve_ok(self):
Expand Down

0 comments on commit f95c712

Please sign in to comment.