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

[Bug] --state flag is not being prioritized over $DBT_STATE environment variable #10413

Closed
2 tasks done
tweavers opened this issue Jul 5, 2024 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@tweavers
Copy link

tweavers commented Jul 5, 2024

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

1.8.3 is not properly setting the --state flag if $DBT_STATE has already been set. We ran into this issue when trying to run dbt ls --select result:success --state target --resource-type model

I added debugging to state.py to get hte following output. In both examples we have $DBT_STATE set.

dbt 1.7.14

$DBT_STATE: ../docs/dbt-docs
state_path:  target

dbt 1.8.3

$DBT_STATE: ../docs/dbt-docs
state_path:  ../docs/dbt-docs

Expected Behavior

--state directory should be prioritized over the $DBT_STATE environment variable

Steps To Reproduce

  1. Set $DBT_STATE to some arbitrary path that is not ./target
  2. Run any dbt build command
  3. Run dbt ls --select result:success --state target
  4. Check the state_path variable that is set in contracts/state.py

Relevant log output

No response

Environment

- OS: MacOS Sonoma 14.5
- Python: Python 3.10.3
- dbt: 1.8.3

Which database adapter are you using with dbt?

Postgres -- v1.8.2

No response

Additional Context

No response

@tweavers tweavers added bug Something isn't working triage labels Jul 5, 2024
@tweavers tweavers changed the title [Bug] --state flag is not being prioritized over $DBT_STATE environment variable [Bug] --state flag is not being prioritized over $DBT_STATE environment variable Jul 6, 2024
@dbeatty10
Copy link
Contributor

Thanks for raising this issue @tweavers!

This looks the same as #10304, so I'm going to close this one as a duplicate.

Workaround

In the meantime, the workaround is to add the --state flag before the ls sub-command like this:

dbt --state target ls --select result:success

Could you let me know if that workaround doesn't behave correctly?

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

tweavers commented Jul 8, 2024

Thanks @dbeatty10 !

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
Projects
None yet
Development

No branches or pull requests

2 participants