Error when RenderConfig.invocation_mode is incorrectly set#2267
Merged
Conversation
✅ Deploy Preview for astronomer-cosmos canceled.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds validation to prevent users from misconfiguring RenderConfig.invocation_mode when dbt is not installed in the same Python environment as Cosmos. The validation catches cases where users incorrectly set InvocationMode.DBT_RUNNER while using a separate dbt virtualenv, which would lead to ModuleNotFoundError: No module named 'dbt'.
Changes:
- Added new helper function
is_dbt_installed_in_same_environment()to check if dbt is available in the current environment - Added validation logic in
validate_initial_user_config()to verify dbt installation and executable path when usingDBT_RUNNERinvocation mode - Added comprehensive test coverage for the new validation scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cosmos/dbt/executable.py | Added helper function to detect if dbt is installed in the current environment |
| cosmos/converter.py | Added validation to check for dbt installation and executable path compatibility when using DBT_RUNNER mode |
| tests/test_converter.py | Added four test cases covering validation scenarios for DBT_RUNNER configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ashb
approved these changes
Jan 14, 2026
Merged
tatiana
added a commit
that referenced
this pull request
Jan 14, 2026
Make our configuration validation more robust, to guide users when they misconfigure Cosmos `RenderConfig.invocation_mode`. This configuration should only be used if dbt is installed in the same Python virtualenv as Cosmos. Recently, I observed a customer incorrectly configuring Cosmos as follows: ``` ExecutionConfig( dbt_executable_path=airflowHome + '/dbt_venv/bin/dbt', execution_mode=ExecutionMode.WATCHER, invocation_mode=InvocationMode.DBT_RUNNER ) ``` Which led to the error: ``` ModuleNotFoundError: No module named 'dbt' ``` This was raised in Cosmos 1.12, when trying to resolve `dbt.version` ``` cosmos/operators/watcher.py:_fallback_to_local_run → build_and_run_cmd → _generate_dbt_flags ``` (cherry picked from commit 4cfac69)
tatiana
added a commit
that referenced
this pull request
Jan 14, 2026
Bug Fixes * Fix ``DbtSourceWatcherOperator.template_fields`` to inherit from ``DbtSourceLocalOperator`` instead of ``DbtConsumerWatcherSensor`` by @pankajkoti in #2226 * Fix TypeError in Watcher mode with subprocess invocation by @pankajkoti in #2227 * Error when RenderConfig.invocation_mode is incorrectly set by @tatiana in #2267 Docs * Fix minor documentation typo by @dnskr in #2093 * Fix default values in documentation by @dnskr in #2092 * Remove emit event for ExecutionMode.AIRFLOW_ASYNC limitation in docs by @pankajastro in #2214 Others * Add test to check profile metrics with non-Cosmos operator by @pankajastro in #2215 * Fix CI main branch Airflow 2.6 tests by @tatiana in #2268 closes: astronomer/oss-integrations-private#295 Co-authored-by: Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
pankajkoti
added a commit
that referenced
this pull request
Jan 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make our configuration validation more robust, to guide users when they misconfigure Cosmos
RenderConfig.invocation_mode.This configuration should only be used if dbt is installed in the same Python virtualenv as Cosmos.
Recently, I observed a customer incorrectly configuring Cosmos as follows:
Which led to the error:
This was raised in Cosmos 1.12, when trying to resolve
dbt.version