dbt-labs / dbt-core

dbt enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
https://getdbt.com
Apache License 2.0
9.96k stars 1.63k forks source link

[Bug] dbt Cloud unable to run without default value for variables used in `dbt_project.yml` #10829

Closed mroy-seedbox closed 1 month ago

mroy-seedbox commented 1 month ago

Is this a new bug in dbt-core?

No, it is a bug/limitation in dbt Cloud. I think it has pretty much always been there, but we just ran into it.

Current Behavior

When a variable is mandatory in dbt_project.yml (no default value is provided), runs in dbt Cloud fail because the variable is not provided when dbt deps is run forcibly.

We do not use packages, so we never run dbt deps locally. And if we did run it, we would be able to provide the variables.

Expected Behavior

Have the ability to disable dbt deps, or even better yet: not run that step at all if no packages.yml file is present!

Or have the ability to specify variables for dbt deps.... but that would mean running it ourselves in our job steps, rather than having it run automatically.

Steps To Reproduce

In dbt_project.yml, add something like this:

models:
  my_project:
    my_database:
      +enabled: "{{ var('enable_my_db') }}"

In dbt cloud, all jobs will fail when running dbt deps:

dbt deps

21:42:17  Encountered an error:
Compilation Error
  Could not render {{ var('enable_my_db') }}: Required var 'enable_my_db' not found in config:
  Vars supplied to  = {}

Environment

- OS: dbt Cloud
- Python: dbt Cloud
- dbt: versionless
dbeatty10 commented 1 month ago

Thanks for reaching out @mroy-seedbox !

Sorry to redirect you, but could you please submit this to the dbt Cloud support team via the "Create a support ticket" or "Leave feedback" button in dbt Cloud or by emailing support@getdbt.com?

I'd also recommend linking to this GitHub issue in your description.

Since this is specific to dbt Cloud and not dbt Core, I'm going to close this issue as "not planned" for the dbt-core repo.

mroy-seedbox commented 1 month ago

@dbeatty10: This might also be fixable in dbt Core by running dbt deps without parsing dbt_project.yml (if that is sensible, but idk if there are any dependencies between the two).

mroy-seedbox commented 1 month ago

Actually, looks like this is a duplicate of #8913.

It would be nice to see a fix for it, just like it was also fixed for env vars in #2368, and for profiles in #4554.

dbeatty10 commented 1 month ago

@mroy-seedbox re-opened https://github.com/dbt-labs/dbt-core/issues/8913 per request 👍