diff --git a/cosmos/dbt/graph.py b/cosmos/dbt/graph.py index 04a7425e7..39ceecc20 100644 --- a/cosmos/dbt/graph.py +++ b/cosmos/dbt/graph.py @@ -180,7 +180,7 @@ def run_command(command: list[str], tmp_dir: Path, env_vars: dict[str, str]) -> ) if returncode or "Error" in stdout.replace("WarnErrorOptions", ""): - details = stderr or stdout + details = f"stderr: {stderr}\nstdout: {stdout}" raise CosmosLoadDbtException(f"Unable to run {command} due to the error:\n{details}") return stdout diff --git a/tests/dbt/test_graph.py b/tests/dbt/test_graph.py index 5d8db4891..f8e191a02 100644 --- a/tests/dbt/test_graph.py +++ b/tests/dbt/test_graph.py @@ -838,7 +838,7 @@ def test_load_via_dbt_ls_with_non_zero_returncode(mock_popen, postgres_profile_c execution_config=execution_config, profile_config=postgres_profile_config, ) - expected = r"Unable to run \['.+dbt', 'deps', .*\] due to the error:\nSome stderr message" + expected = r"Unable to run \['.+dbt', 'deps', .*\] due to the error:\nstderr: Some stderr message\nstdout: " with pytest.raises(CosmosLoadDbtException, match=expected): dbt_graph.load_via_dbt_ls() @@ -859,7 +859,7 @@ def test_load_via_dbt_ls_with_runtime_error_in_stdout(mock_popen_communicate, po execution_config=execution_config, profile_config=postgres_profile_config, ) - expected = r"Unable to run \['.+dbt', 'deps', .*\] due to the error:\nSome Runtime Error" + expected = r"Unable to run \['.+dbt', 'deps', .*\] due to the error:\nstderr: \nstdout: Some Runtime Error" with pytest.raises(CosmosLoadDbtException, match=expected): dbt_graph.load_via_dbt_ls() @@ -1131,7 +1131,7 @@ def test_run_command_none_argument(mock_popen, caplog): with pytest.raises(CosmosLoadDbtException) as exc_info: run_command(fake_command, fake_dir, env_vars) - expected = "Unable to run ['invalid-cmd', ''] due to the error:\nInvalid None argument" + expected = "Unable to run ['invalid-cmd', ''] due to the error:\nstderr: None\nstdout: Invalid None argument" assert str(exc_info.value) == expected