diff --git a/python_modules/libraries/dagster-dbt/dagster_dbt/core/resources_v2.py b/python_modules/libraries/dagster-dbt/dagster_dbt/core/resources_v2.py index 5b5c85e9284a7..115f2e1c86559 100644 --- a/python_modules/libraries/dagster-dbt/dagster_dbt/core/resources_v2.py +++ b/python_modules/libraries/dagster-dbt/dagster_dbt/core/resources_v2.py @@ -604,19 +604,22 @@ def validate_project_dir(cls, project_dir: str) -> str: return os.fspath(resolved_project_dir) @validator("profiles_dir") - def validate_profiles_dir(cls, profiles_dir: str) -> str: - resolved_project_dir = cls._validate_absolute_path_exists(profiles_dir) + def validate_profiles_dir(cls, profiles_dir: Optional[str]) -> Optional[str]: + if profiles_dir is None: + return None + + resolved_profiles_dir = cls._validate_absolute_path_exists(profiles_dir) cls._validate_path_contains_file( - path=resolved_project_dir, + path=resolved_profiles_dir, file_name=DBT_PROFILES_YML_NAME, error_message=( - f"{resolved_project_dir} does not contain a {DBT_PROFILES_YML_NAME} file. Please" + f"{resolved_profiles_dir} does not contain a {DBT_PROFILES_YML_NAME} file. Please" " specify a valid path to a dbt profile directory." ), ) - return os.fspath(resolved_project_dir) + return os.fspath(resolved_profiles_dir) @validator("dbt_executable") def validate_dbt_executable(cls, dbt_executable: str) -> str: diff --git a/python_modules/libraries/dagster-dbt/dagster_dbt_tests/core/test_resources_v2.py b/python_modules/libraries/dagster-dbt/dagster_dbt_tests/core/test_resources_v2.py index 07cf3669b6ef4..530326d38b799 100644 --- a/python_modules/libraries/dagster-dbt/dagster_dbt_tests/core/test_resources_v2.py +++ b/python_modules/libraries/dagster-dbt/dagster_dbt_tests/core/test_resources_v2.py @@ -215,8 +215,8 @@ def test_dbt_profile_configuration() -> None: assert dbt_cli_invocation.is_successful() -@pytest.mark.parametrize("profiles_dir", [TEST_PROJECT_DIR, Path(TEST_PROJECT_DIR)]) -def test_dbt_profile_dir_configuration(profiles_dir: Union[str, Path]) -> None: +@pytest.mark.parametrize("profiles_dir", [None, TEST_PROJECT_DIR, Path(TEST_PROJECT_DIR)]) +def test_dbt_profiles_dir_configuration(profiles_dir: Union[str, Path]) -> None: dbt = DbtCliResource( project_dir=TEST_PROJECT_DIR, profiles_dir=profiles_dir, # type: ignore