Skip to content

fix: dependencies installation with project level variables#1822

Merged
tatiana merged 3 commits into
astronomer:mainfrom
AlexandrKhabarov:fix/deps-installation
Jun 30, 2025
Merged

fix: dependencies installation with project level variables#1822
tatiana merged 3 commits into
astronomer:mainfrom
AlexandrKhabarov:fix/deps-installation

Conversation

@AlexandrKhabarov
Copy link
Copy Markdown
Contributor

@AlexandrKhabarov AlexandrKhabarov commented Jun 22, 2025

Description

Failed at runtime phase during dependencies installation if project level variables are used

dbt deps \
    --target $FLOPPA_TARGET \
    --profiles-dir $FLOPPA_FOLDER \
    --project-dir $FLOPPA_FOLDER
14:43:11  Running with dbt=1.8.9
14:43:11  Encountered an error:
Compilation Error
  Could not render ingestion_date = '{{ var("ingestion_date") }}': Required var 'ingestion_date' not found in config:
  Vars supplied to <Configuration> = {}

Related Issue(s)

Breaking Change?

No breaking changes

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 22, 2025

Deploy Preview for sunny-pastelito-5ecb04 canceled.

Name Link
🔨 Latest commit 7af101e
🔍 Latest deploy log https://app.netlify.com/projects/sunny-pastelito-5ecb04/deploys/685815617ce45f0008f36abd

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 22, 2025

Deploy Preview for sunny-pastelito-5ecb04 canceled.

Name Link
🔨 Latest commit 64b996d
🔍 Latest deploy log https://app.netlify.com/projects/sunny-pastelito-5ecb04/deploys/685978c6b18ec40008b5a048

@AlexandrKhabarov
Copy link
Copy Markdown
Contributor Author

@tatiana can you take a look, please?

Copy link
Copy Markdown
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AlexandrKhabarov thank you very much for reporting this issue and fixing it.

Would it be possible to add a test to confirm that when using local execution mode these flags are being passed, as desired?

Also, which LoadMode are you using? We may not be handling this use case when installing deps in LoadMode.DBT_LS (

def run_dbt_deps(self, dbt_cmd: str, dbt_project_path: Path, env: dict[str, str]) -> None:
"""
Given the dbt command path and the dbt project path, build and run the dbt deps command.
"""
deps_command = [dbt_cmd, "deps"]
deps_command.extend(self.local_flags)
self._add_vars_arg(deps_command)
run_command(deps_command, dbt_project_path, env, self.render_config.invocation_mode, self.log_dir)
). If you could confirm if that is the case, we could create a follow-up ticket to address this.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.01%. Comparing base (389e1bf) to head (64b996d).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1822   +/-   ##
=======================================
  Coverage   98.01%   98.01%           
=======================================
  Files          85       85           
  Lines        5290     5290           
=======================================
  Hits         5185     5185           
  Misses        105      105           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlexandrKhabarov
Copy link
Copy Markdown
Contributor Author

Hello @tatiana

I think that such test exists - https://github.com/astronomer/astronomer-cosmos/blob/main/tests/dbt/test_graph.py#L1837

I am using LoadMode.AUTOMATIC. DBT_LS is part of it

@AlexandrKhabarov
Copy link
Copy Markdown
Contributor Author

Also, I created a PR in a past to fix problem with parsing - #1543

@AlexandrKhabarov AlexandrKhabarov requested a review from tatiana June 24, 2025 23:56
@tatiana
Copy link
Copy Markdown
Collaborator

tatiana commented Jun 25, 2025

Thank you very much, @AlexandrKhabarov !

The test https://github.com/astronomer/astronomer-cosmos/blob/main/tests/dbt/test_graph.py#L1837 covers the issue in the DAG parsing/rendering while converting during the dbt ls command execution - so apparently the problem was already solved there.

Since you fixed the behaviour in the local operator execution, it may be worth adapting or adding a test in https://github.com/astronomer/astronomer-cosmos/blob/main/tests/operators/test_local.py
To make sure we don't cause any regressions, and this fix remains there.

It could be a very similar test to what you did in the test tests/operators/test_virtualenv.py validates that --vars were not set. In the case of the local operator, we'd like to confirm that we're setting the correct arguments when trying to run deps from there.

@tatiana tatiana merged commit 12ec083 into astronomer:main Jun 30, 2025
85 checks passed
@tatiana tatiana mentioned this pull request Aug 7, 2025
tatiana pushed a commit that referenced this pull request Aug 7, 2025
## Description

Failed at runtime phase during dependencies installation if project
level variables are used
```
dbt deps \
    --target $FLOPPA_TARGET \
    --profiles-dir $FLOPPA_FOLDER \
    --project-dir $FLOPPA_FOLDER
14:43:11  Running with dbt=1.8.9
14:43:11  Encountered an error:
Compilation Error
  Could not render ingestion_date = '{{ var("ingestion_date") }}': Required var 'ingestion_date' not found in config:
  Vars supplied to <Configuration> = {}
```

## Related Issue(s)

## Breaking Change?

No breaking changes

## Checklist

- [ ] I have made corresponding changes to the documentation (if
required)
- [X] I have added tests that prove my fix is effective or that my
feature works

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 12ec083)
tatiana added a commit that referenced this pull request Aug 8, 2025
**Bug Fixes**

* Fix task instance ``try_number`` attribute for Airflow 3 compatibility
by @pankajkoti in #1781
* Fix rendered template override logic when
``should_store_compiled_sql=False`` to restore pre-refactor behaviour by
@pankajkoti in #1777
* Fix ``ProfileConfig`` in GCP Cloud Run job execution mode by
@ramonvermeulen in #1783
* Fix dbt Docs page height by @1cadumagalhaes in #1793
* Add support to base64 encoded pem in Snowflake profiles by
@brunocmartins in #1801
* Allow to disable owner inheritance from dbt into airflow DAG owners by
@CorsettiS in #1787
* Fix Kubernetes Pod Operator conversion of ``container_resources`` to
``resources`` by @johnhoran in #1821
* Fix ``dbt deps`` with project level variables by @AlexandrKhabarov in
#1822
* Fix source freshness warnings in kubernetes execution mode by
@Pawel-Drabczyk in #1859
* Fix: Harden DbtNode against null config/meta by @pankajkoti in #1877
* Fix cache behaviour when DAG name contains "." by @tatiana in #1908

**Documentation**

* Fix ``contributing.rst`` docs by @tatiana in #1785
* Fix docs rendering in Airflow 3 Compatibility by @pankajastro in #1790
* Fix typo in ``selecting-excluding.rst`` by @msshroff in #1814
* Update testing behavior file with ``ExecutionMode.KUBERNETES`` by
@LuigiCerone in #1813
* Add step to fork repo in contributing guide by @pankajastro in #1808
* Fix ``depends_on`` attribute by @benedikt-buchert in #1837
* Fix character name by @ThePsyjo in #1860
* Update suggested MWAA startup script by @jaklan in #1884
* Make implementation & docs consistent regarding
``use_dataset_airflow3_uri_standard`` by @Anti0ff in #1878

**Others**

* Set retries to 0 in example DAGs by @pankajkoti in #1782
* Fix ``test_async_example_dag_without_setup_task`` tests by
@pankajastro in #1788
* Fix test hash value for Darwin when using Py 3.12.10 by @tatiana in
#1786
* Upgrade Python and Airflow used to run MyPy checks by @tatiana in
#1796
* Assert example DAGs' ``DagRunState`` and fix issues by @pankajkoti and
@tatiana in #1778
* Update the conflict matrix to include AF 2.10, 2.11 & 3.0 and dbt 1.9
& 1.10 by @tatiana in #1820
* Fix broken CI due to Pydantic conflicts by @tatiana in #1809
* Drop Python 3.8 Support by @pankajastro in #1852
* Add Airflow 2.11 to the test matrix by @tatiana in #1807
* Require Authorize for all jobs on pull requests from external
contributors in CI by @pankajkoti in #1861
* Leverage Trusted Publisher Management when publishing PyPI package by
@tatiana in #1862
* CI: Add back accidentally deleted python-version matrix for running
unit tests by @pankajkoti in #1872
* Remove commented code and fix mypy failures by @pankajkoti in #1876
* Add Zizmor analysis GitHub action by @pankajkoti in #1870
* Catch FlushError on Datasets for Airflow 2.11 dags test by @pankajkoti
in #1880
* Add deprecation warning for ``LoadMode.CUSTOM`` parser by
@duongphannamhung in #1885
* CI: Add GitHub CodeQL analysis workflow (codeql.yml) by @pankajkoti in
#1871
* Resolve 'credential persistence through GitHub Actions artifacts'
warnings from Zizmor by @pankajkoti in #1890
* Resolve 'overly broad permissions' warnings from Zizmor by @pankajkoti
in #1889
* Resolve Zizmor error alerts for unpinned image references; mark alert
for pull_request_target ignored by @pankajkoti in #1888
* Fix broken CI ``tests.py3.11-2.8-1.9:test-integration-setup`` by
@tatiana in #1902
* Add dbt-core 1.10 to test matrix by @tatiana in #1767
* Pin package dbt-databricks by @pankajastro in #1909
* Enable matrix test entry for dbt-1.9, python-3.9 and airflow-3.0 tests
in CI by @pankajastro in #1900
* Pre-commit updates: #1779, #1795, #1800, #1857, #1863, #1869, #1892,
#1901
* Dependabot updates: #1904

Co-authored-by: Pankaj Koti <pankajkoti699@gmail.com>
@pankajkoti pankajkoti mentioned this pull request Aug 8, 2025
tatiana added a commit that referenced this pull request Aug 8, 2025
**Bug Fixes**

* Fix task instance ``try_number`` attribute for Airflow 3 compatibility
by @pankajkoti in #1781
* Fix rendered template override logic when
``should_store_compiled_sql=False`` to restore pre-refactor behaviour by
@pankajkoti in #1777
* Fix ``ProfileConfig`` in GCP Cloud Run job execution mode by
@ramonvermeulen in #1783
* Fix dbt Docs page height by @1cadumagalhaes in #1793
* Add support to base64 encoded pem in Snowflake profiles by
@brunocmartins in #1801
* Allow to disable owner inheritance from dbt into airflow DAG owners by
@CorsettiS in #1787
* Fix Kubernetes Pod Operator conversion of ``container_resources`` to
``resources`` by @johnhoran in #1821
* Fix ``dbt deps`` with project level variables by @AlexandrKhabarov in
#1822
* Fix source freshness warnings in kubernetes execution mode by
@Pawel-Drabczyk in #1859
* Fix: Harden DbtNode against null config/meta by @pankajkoti in #1877
* Fix cache behaviour when DAG name contains "." by @tatiana in #1908

**Documentation**

* Fix ``contributing.rst`` docs by @tatiana in #1785
* Fix docs rendering in Airflow 3 Compatibility by @pankajastro in #1790
* Fix typo in ``selecting-excluding.rst`` by @msshroff in #1814
* Update testing behavior file with ``ExecutionMode.KUBERNETES`` by
@LuigiCerone in #1813
* Add step to fork repo in contributing guide by @pankajastro in #1808
* Fix ``depends_on`` attribute by @benedikt-buchert in #1837
* Fix character name by @ThePsyjo in #1860
* Update suggested MWAA startup script by @jaklan in #1884
* Make implementation & docs consistent regarding
``use_dataset_airflow3_uri_standard`` by @Anti0ff in #1878

**Others**

* Set retries to 0 in example DAGs by @pankajkoti in #1782
* Fix ``test_async_example_dag_without_setup_task`` tests by
@pankajastro in #1788
* Fix test hash value for Darwin when using Py 3.12.10 by @tatiana in
#1786
* Upgrade Python and Airflow used to run MyPy checks by @tatiana in
#1796
* Assert example DAGs' ``DagRunState`` and fix issues by @pankajkoti and
@tatiana in #1778
* Update the conflict matrix to include AF 2.10, 2.11 & 3.0 and dbt 1.9
& 1.10 by @tatiana in #1820
* Fix broken CI due to Pydantic conflicts by @tatiana in #1809
* Drop Python 3.8 Support by @pankajastro in #1852
* Add Airflow 2.11 to the test matrix by @tatiana in #1807
* Require Authorize for all jobs on pull requests from external
contributors in CI by @pankajkoti in #1861
* Leverage Trusted Publisher Management when publishing PyPI package by
@tatiana in #1862
* CI: Add back accidentally deleted python-version matrix for running
unit tests by @pankajkoti in #1872
* Remove commented code and fix mypy failures by @pankajkoti in #1876
* Add Zizmor analysis GitHub action by @pankajkoti in #1870
* Catch FlushError on Datasets for Airflow 2.11 dags test by @pankajkoti
in #1880
* Add deprecation warning for ``LoadMode.CUSTOM`` parser by
@duongphannamhung in #1885
* CI: Add GitHub CodeQL analysis workflow (codeql.yml) by @pankajkoti in
#1871
* Resolve 'credential persistence through GitHub Actions artifacts'
warnings from Zizmor by @pankajkoti in #1890
* Resolve 'overly broad permissions' warnings from Zizmor by @pankajkoti
in #1889
* Resolve Zizmor error alerts for unpinned image references; mark alert
for pull_request_target ignored by @pankajkoti in #1888
* Fix broken CI ``tests.py3.11-2.8-1.9:test-integration-setup`` by
@tatiana in #1902
* Add dbt-core 1.10 to test matrix by @tatiana in #1767
* Pin package dbt-databricks by @pankajastro in #1909
* Enable matrix test entry for dbt-1.9, python-3.9 and airflow-3.0 tests
in CI by @pankajastro in #1900
* Pre-commit updates: #1779, #1795, #1800, #1857, #1863, #1869, #1892,
#1901
* Dependabot updates: #1904

Co-authored-by: Tatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
@tatiana tatiana added this to the Cosmos 1.10.2 milestone Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants