From ca9b1d304d2b04648a6cd0e0300a9f48664f85d5 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Fri, 19 Apr 2024 07:53:39 -0500 Subject: [PATCH] validate packages are not empty strings --- core/dbt/contracts/project.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index 46c9742952f..5606d78c1c4 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -101,13 +101,26 @@ class PackageConfig(dbtClassMixin): @classmethod def validate(cls, data): for package in data.get("packages", data): + # This can happen when the target is a variable that is not filled and results in hangs + if isinstance(package, dict): + if package.get("package") == "": + raise ValidationError( + "A package package is missing the value. It is a required property" + ) + if package.get("local") == "": + raise ValidationError( + "A local package is missing the value. It is a required property" + ) + if package.get("git") == "": + raise ValidationError( + "A git package is missing the value. It is a required property" + ) if isinstance(package, dict) and package.get("package"): if not package["version"]: raise ValidationError( f"{package['package']} is missing the version. When installing from the Hub " "package index, version is a required property" ) - if "/" not in package["package"]: raise ValidationError( f"{package['package']} was not found in the package index. Packages on the index "