From 79227b4d346b505f9f6abcbd0921074e8fe365e9 Mon Sep 17 00:00:00 2001 From: Doug Beatty Date: Sat, 23 Mar 2024 13:20:31 -0600 Subject: [PATCH] Make a copy of `args` passed to `make_dbt_context` --- core/dbt/cli/context.py | 2 +- core/dbt/cli/flags.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/dbt/cli/context.py b/core/dbt/cli/context.py index b8f541b9ad8..90d8caf1c1d 100644 --- a/core/dbt/cli/context.py +++ b/core/dbt/cli/context.py @@ -6,7 +6,7 @@ def make_context(args, command=dbt) -> Optional[click.Context]: try: - ctx = command.make_context(command.name, args) + ctx = command.make_context(command.name, args.copy()) except click.exceptions.Exit: return None diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index 92a6cbc5a28..353a7735432 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -64,7 +64,7 @@ def args_to_context(args: List[str]) -> Context: """Convert a list of args to a click context with proper hierarchy for dbt commands""" from dbt.cli.main import cli - cli_ctx = cli.make_context(cli.name, args) + cli_ctx = cli.make_context(cli.name, args.copy()) # Split args if they're a comma separated string. if len(args) == 1 and "," in args[0]: args = args[0].split(",") @@ -74,7 +74,7 @@ def args_to_context(args: List[str]) -> Context: sub_command_name, sub_command, args = sub_command.resolve_command(cli_ctx, args) assert isinstance(sub_command, ClickCommand) - sub_command_ctx = sub_command.make_context(sub_command_name, args) + sub_command_ctx = sub_command.make_context(sub_command_name, args.copy()) sub_command_ctx.parent = cli_ctx return sub_command_ctx @@ -218,7 +218,7 @@ def _assign_params( invoked_subcommand = getattr(import_module("dbt.cli.main"), invoked_subcommand_name) invoked_subcommand.allow_extra_args = True invoked_subcommand.ignore_unknown_options = True - invoked_subcommand_ctx = invoked_subcommand.make_context(None, sys.argv) + invoked_subcommand_ctx = invoked_subcommand.make_context(None, sys.argv.copy()) _assign_params( invoked_subcommand_ctx, params_assigned_from_default,