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] env var DBT_TARGET violates the rule of specificity #10425

Closed
2 tasks done
owenprough-sift opened this issue Jul 10, 2024 · 4 comments
Closed
2 tasks done
Labels
bug Something isn't working duplicate This issue or pull request already exists regression

Comments

@owenprough-sift
Copy link

Is this a new bug in dbt-core?

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

Current Behavior

dbt improperly ignores the --target CLI flag when environment variable DBT_TARGET is set.

$ export DBT_TARGET=nonvalid_target
$ dbt build --project-dir /dbt --target dev
12:31:08  Running with dbt=1.8.3
12:31:08  Encountered an error:
Runtime Error
  The profile 'xxx' does not have a target named 'nonvalid_target'. The valid target names for this profile are: 
   - dev
   - prod

Expected Behavior

According to the documentation regarding flags (link):

The most specific setting "wins." If you set the same flag in all three places, the CLI option will take precedence, followed by the environment variable, and finally, the value in dbt_project.yml.

So I would expect the --target CLI option to be used even though the env var is set.

Steps To Reproduce

  1. Set environment variable DBT_TARGET
  2. Invoke dbt, passing the --target option for a target different than the contents of DBT_TARGET
  3. Weep when dbt ignores --target and uses instead the contents of DBT_TARGET

Relevant log output

No response

Environment

- OS: Debian 11 (official python docker image `python:3.11-slim-bullseye`)
- Python: 3.11.9
- dbt: 1.8.3
- dbt-snowflake: 1.8.3

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@owenprough-sift owenprough-sift added bug Something isn't working triage labels Jul 10, 2024
@dbeatty10
Copy link
Contributor

Thank you for raising this issue @owenprough-sift -- agreed that dbt should use the value of --target instead of DBT_TARGET 🎯

This looks like the issue reported in #10304.

What happens when you move --target to be before the build subcommand?

@dbeatty10 dbeatty10 changed the title [Bug] env var DBT_TARGET violates the rule of specificity [Regression] env var DBT_TARGET violates the rule of specificity Jul 10, 2024
@owenprough-sift
Copy link
Author

dbt --target dev build ... works as expected. But I'd still like #10304 to be fixed. 😉

@dbeatty10
Copy link
Contributor

But I'd still like #10304 to be fixed. 😉

💯 ! We've got a fix in flight: #10423

In the meantime, I'm going to close this one as a special case of #10304

Thank you as always for your insights on what is/isn't working as it should 🙏

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
@dbeatty10 dbeatty10 added duplicate This issue or pull request already exists and removed triage labels Jul 10, 2024
@dbeatty10
Copy link
Contributor

@owenprough-sift we just merged #10423. Once #10427 is also merged, then it will go in the next patch release for dbt 1.8.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists regression
Projects
None yet
Development

No branches or pull requests

2 participants