[Bug] cli.make_context()
is not idempotent when passing the same args
#9787
Labels
bug
Something isn't working
Is this a new bug in dbt-core?
Current Behavior
Calling
cli.make_context()
twice with the sameargs
leads to a failing test upon the 2nd invocation.Expected Behavior
I'd expect
cli.make_context()
to be idempotent like looking at a slice of cake rather than eating a slice of cake. e.g., I should be able to call it with the sameargs
object repeatedly and get the same result.Steps To Reproduce
Add the following test to
tests/unit/test_cli_flags.py
:Then run it like this:
Relevant log output
Environment
Which database adapter are you using with dbt?
No response
Additional Context
If the following edit is made to the code example above, then it will work:
Alternatively, an equivalent change can be made here instead:
We can see an example within the
click
source code here of making a copy of theargs
when callingcli.make_context
:So that makes it seem like someone else has bumped into a similar issue before.
My guess is that Click's
make_context
is mutating theargs
list which is creates an issue if is re-used a second time in a subsequent call tomake_context
.If so, then the best solution would be if
make_context
didn't mutate the list.But in the meantime, it would behoove us to make a copy of any
args
variables being passed intocli.make_context
.The text was updated successfully, but these errors were encountered: