diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef13dea2..029b7f82a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,12 @@ ### Fixes - Reimplement the `unique` test to handle column expressions and naming overlaps ([#33](https://github.com/dbt-labs/dbt-bigquery/issues/33), [#35](https://github.com/dbt-labs/dbt-bigquery/issues/35), [#10](https://github.com/dbt-labs/dbt-bigquery/pull/10)) +- Avoid error in `dbt deps` + `dbt clean` if default project is missing ([#27](https://github.com/dbt-labs/dbt-bigquery/issues/27), [#40](https://github.com/dbt-labs/dbt-bigquery/pull/40)) ### Contributors - [@DigUpTheHatchet](https://github.com/DigUpTheHatchet) ([#10](https://github.com/dbt-labs/dbt-bigquery/pull/10)) +- [@jeremyyeo](https://github.com/jeremyyeo) ([#40](https://github.com/dbt-labs/dbt-bigquery/pull/40)) ## dbt-bigquery 1.0.0b1 (October 11, 2021) diff --git a/dbt/adapters/bigquery/connections.py b/dbt/adapters/bigquery/connections.py index 265959400..d6988103c 100644 --- a/dbt/adapters/bigquery/connections.py +++ b/dbt/adapters/bigquery/connections.py @@ -21,10 +21,11 @@ from dbt.adapters.bigquery import gcloud from dbt.utils import format_bytes, format_rows_number from dbt.clients import agate_helper +from dbt.config.profile import INVALID_PROFILE_MESSAGE from dbt.tracking import active_user from dbt.contracts.connection import ConnectionState, AdapterResponse from dbt.exceptions import ( - FailedToConnectException, RuntimeException, DatabaseException + FailedToConnectException, RuntimeException, DatabaseException, DbtProfileError ) from dbt.adapters.base import BaseConnectionManager, Credentials from dbt.logger import GLOBAL_LOGGER as logger @@ -58,7 +59,11 @@ def get_bigquery_defaults(scopes=None) -> Tuple[Any, Optional[str]]: project_id is returned available from the environment; otherwise None """ # Cached, because the underlying implementation shells out, taking ~1s - return google.auth.default(scopes=scopes) + try: + credentials, _ = google.auth.default(scopes=scopes) + return credentials, _ + except google.auth.exceptions.DefaultCredentialsError as e: + raise DbtProfileError(INVALID_PROFILE_MESSAGE.format(error_string=e)) class Priority(StrEnum):