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] CLI flags do not take precedence over env var DBT_DEFER_STATE #11216

Open
2 tasks done
Siete-F opened this issue Jan 16, 2025 · 1 comment
Open
2 tasks done

[Bug] CLI flags do not take precedence over env var DBT_DEFER_STATE #11216

Siete-F opened this issue Jan 16, 2025 · 1 comment
Labels
awaiting_response bug Something isn't working

Comments

@Siete-F
Copy link

Siete-F commented Jan 16, 2025

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

When specifying the env var DBT_DEFER_STATE=stateprod, it appears to be considered even when you try to overrule the state manually using dbt test --defer --state state (non-prod)

Do I miss something regarding

Expected Behavior

Expected to be able to overwrite the state using the flags, as stated in the docs: https://docs.getdbt.com/reference/node-selection/syntax#establishing-state

Steps To Reproduce

The following example results in stateprod being used as state.

Image

When doing the same with DBT_STATE (and unsetting DBT_DEFER_STATE), it works as expected, and the flag gets precedence. i.e. the used state is 'state'

Image

Relevant log output

NA

Environment

- OS: Windows 11
- Python: 3.10.5
- dbt: 1.8.7

Which database adapter are you using with dbt?

spark

Additional Context

I noticed that the on-run-end DOES use the expected state (provided via the cli flags) when having DBT_DEFER_STATE set! Causing inconsistent catalogs being referred in my case.

@Siete-F Siete-F added bug Something isn't working triage labels Jan 16, 2025
@dbeatty10
Copy link
Contributor

Thanks for reaching out @Siete-F !

Did you try the --defer-state flag? That's the one that overrides the DBT_DEFER_STATE environment variable:

Image

More info / examples in the docs here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting_response bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants