diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4c25a1a42..945f204c028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Add generic tests defined on sources to the manifest once, not twice ([#3347](https://github.com/dbt-labs/dbt/issues/3347), [#3880](https://github.com/dbt-labs/dbt/pull/3880)) - Skip partial parsing if certain macros have changed ([#3810](https://github.com/dbt-labs/dbt/issues/3810), [#3982](https://github.com/dbt-labs/dbt/pull/3892)) - Enable cataloging of unlogged Postgres tables ([3961](https://github.com/dbt-labs/dbt/issues/3961), [#3993](https://github.com/dbt-labs/dbt/pull/3993)) +- Return an error instead of a warning when runing with `--warn-error` and no models are selected ([#4006](https://github.com/dbt-labs/dbt/issues/4006), [#4019](https://github.com/dbt-labs/dbt/pull/4019)) ### Under the hood @@ -34,6 +35,7 @@ Contributors: - [@dave-connors-3](https://github.com/dave-connors-3) ([#3920](https://github.com/dbt-labs/dbt/issues/3920)) - [@kadero](https://github.com/kadero) ([#3952](https://github.com/dbt-labs/dbt/issues/3952)) - [@samlader](https://github.com/samlader) ([#3993](https://github.com/dbt-labs/dbt/pull/3993)) +- [@laxjesse](https://github.com/laxjesse) ([#4019](https://github.com/dbt-labs/dbt/pull/4019)) ## dbt 0.21.0 (October 04, 2021) diff --git a/core/dbt/task/list.py b/core/dbt/task/list.py index 85277e07b7e..19240321afa 100644 --- a/core/dbt/task/list.py +++ b/core/dbt/task/list.py @@ -8,8 +8,8 @@ from dbt.task.runnable import GraphRunnableTask, ManifestTask from dbt.task.test import TestSelector from dbt.node_types import NodeType -from dbt.exceptions import RuntimeException, InternalException -from dbt.logger import log_manager, GLOBAL_LOGGER as logger +from dbt.exceptions import RuntimeException, InternalException, warn_or_error +from dbt.logger import log_manager class ListTask(GraphRunnableTask): @@ -61,7 +61,7 @@ def _iterate_selected_nodes(self): spec = self.get_selection_spec() nodes = sorted(selector.get_selected(spec)) if not nodes: - logger.warning('No nodes selected!') + warn_or_error('No nodes selected!') return if self.manifest is None: raise InternalException( diff --git a/core/dbt/task/runnable.py b/core/dbt/task/runnable.py index 0e3c088b573..dd17c00e5b7 100644 --- a/core/dbt/task/runnable.py +++ b/core/dbt/task/runnable.py @@ -39,6 +39,7 @@ NotImplementedException, RuntimeException, FailFastException, + warn_or_error, ) from dbt.graph import ( @@ -438,8 +439,8 @@ def run(self): ) if len(self._flattened_nodes) == 0: - logger.warning("\nWARNING: Nothing to do. Try checking your model " - "configs and model specification args") + warn_or_error("\nWARNING: Nothing to do. Try checking your model " + "configs and model specification args") result = self.get_result( results=[], generated_at=datetime.utcnow(),