Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression] Jinja templating not working in dependencies.yml #11109

Closed
2 tasks done
H-Max opened this issue Dec 9, 2024 · 4 comments
Closed
2 tasks done

[Regression] Jinja templating not working in dependencies.yml #11109

H-Max opened this issue Dec 9, 2024 · 4 comments
Labels
bug Something isn't working regression wontfix Not a bug or out of scope for dbt-core

Comments

@H-Max
Copy link

H-Max commented Dec 9, 2024

Is this a regression in a recent version of dbt-core?

  • I believe this is a regression in dbt-core functionality
  • I have searched the existing issues, and I could not find an existing issue for this regression

Current Behavior

packages.yml file supports jinja templating, at least to read environment variables with env_var().

For instance:

packages:
  - package: dbt-labs/dbt_utils
    version: '{{ env_var("DBT_UTILS_VERSION", "1.3.0") }}'

This does not work anymore when renaming the file to dependencies.yml and this will be an issue in the future.

We use this to pull private dbt packages from gitlab repositories using a syntax like that:

packages:
  - package: dbt-labs/dbt_utils
    version: 1.3.0
  - git: "https://{{ ('gitlab-ci-token:' ~ env_var('CI_JOB_TOKEN') ~ '@') if env_var('CI_JOB_TOKEN', '') }}gitlab.com/path/to/my/package"
    revision: 1.1.1

Expected/Previous Behavior

Jinja templating should be re-enabled in the file dependencies.yml

Steps To Reproduce

Simply add jinja templating trying to read an existing (or not) environment variable in dependencies.yml and you'll get a syntax error.

Relevant log output

No response

Environment

- OS: MacOS
- Python: 3.11.9
- dbt (working version): whatever the version if you're using packages.yml
- dbt (regression version): whatever the version if you're switching to dependencies.yml

Which database adapter are you using with dbt?

bigquery

Additional Context

No response

@H-Max H-Max added bug Something isn't working regression triage labels Dec 9, 2024
@dbeatty10
Copy link
Contributor

Hey @H-Max ! I see what you are saying about Jinja templating not being supported in dependencies.yml and how this affects using environment variables for private packages within dependencies.yml.

The solution for your case:

  1. Keep any package dependencies within your existing packages.yml file
  2. Add any project dependencies to a brand-new dependencies.yml file.

Relevant documentation

We have this documented here, but it is easy to miss:

image

Next steps

We intentionally chose for dependencies.yml to not include Jinja rendering, so I'm going to close this as not a bug or a regression.

Rather, you can keep any dbt packages that need Jinja rendering within your packages.yml file and use it alongside a new dependencies.yml file.

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
@dbeatty10 dbeatty10 added wontfix Not a bug or out of scope for dbt-core and removed triage labels Dec 9, 2024
@H-Max
Copy link
Author

H-Max commented Dec 9, 2024

Thanks Doug for the heads up to the documentation. I did miss it.

I really thought I read somewhere that it was a good practice to move everything to dependencies.yml, and I wonder if there wasn't a time when there was a warning about packages.yml depreciation, but I am may be wrong about that.

Thanks again for the quick reply on the issue !

@dbeatty10
Copy link
Contributor

I really thought I read somewhere that it was a good practice to move everything to dependencies.yml, and I wonder if there wasn't a time when there was a warning about packages.yml depreciation, but I am may be wrong about that.

You have a good memory @H-Max 🧠

Our original guidance was to move everything to dependencies.yml. The problem is that not everyone can do that. So we updated our guidance in dbt-labs/docs.getdbt.com#6129 / dbt-labs/docs.getdbt.com#6171.

@H-Max
Copy link
Author

H-Max commented Dec 10, 2024

You have a good memory @H-Max 🧠

I knew it ! I'm not mad ! :D

Well, as long as you don't plan on removing jinja / env_var support in packages.yml, I'm fine with it !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

2 participants