From 9e83e02c366186209dd566d8bbef10d53563eaee Mon Sep 17 00:00:00 2001 From: aemous Date: Mon, 8 Dec 2025 11:00:27 -0500 Subject: [PATCH 1/5] Reduced false positive upgrade warnings for URL parameters. --- awscli/argprocess.py | 3 ++- awscli/clidriver.py | 10 +++++----- awscli/customizations/globalargs.py | 15 --------------- awscli/paramfile.py | 23 +++++++++++++++++++---- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/awscli/argprocess.py b/awscli/argprocess.py index 14bc648e3edd..af59b08adb37 100644 --- a/awscli/argprocess.py +++ b/awscli/argprocess.py @@ -65,7 +65,7 @@ class TooComplexError(Exception): def unpack_argument( - session, service_name, operation_name, cli_argument, value + session, service_name, operation_name, cli_argument, value, parsed_globals ): """ Unpack an argument's value from the commandline. This is part one of a two @@ -83,6 +83,7 @@ def unpack_argument( value=value, service_name=service_name, operation_name=operation_name, + parsed_globals=parsed_globals, ) if value_override is not None: diff --git a/awscli/clidriver.py b/awscli/clidriver.py index 07d12131af68..83c83bae23e9 100644 --- a/awscli/clidriver.py +++ b/awscli/clidriver.py @@ -542,7 +542,7 @@ def __call__(self, args, parsed_globals): event, parsed_args=parsed_args, parsed_globals=parsed_globals ) call_parameters = self._build_call_parameters( - parsed_args, self.arg_table + parsed_args, self.arg_table, parsed_globals ) self._detect_binary_file_migration_change( @@ -596,7 +596,7 @@ def _add_help(self, parser): # CLIArguments for values. parser.add_argument('help', nargs='?') - def _build_call_parameters(self, args, arg_table): + def _build_call_parameters(self, args, arg_table, parsed_globals): # We need to convert the args specified on the command # line as valid **kwargs we can hand to botocore. service_params = {} @@ -607,11 +607,11 @@ def _build_call_parameters(self, args, arg_table): py_name = arg_object.py_name if py_name in parsed_args: value = parsed_args[py_name] - value = self._unpack_arg(arg_object, value) + value = self._unpack_arg(arg_object, value, parsed_globals) arg_object.add_to_params(service_params, value) return service_params - def _unpack_arg(self, cli_argument, value): + def _unpack_arg(self, cli_argument, value, parsed_globals): # Unpacks a commandline argument into a Python value by firing the # load-cli-arg.service-name.operation-name event. session = self._session @@ -619,7 +619,7 @@ def _unpack_arg(self, cli_argument, value): operation_name = xform_name(self._name, '-') return unpack_argument( - session, service_name, operation_name, cli_argument, value + session, service_name, operation_name, cli_argument, value, parsed_globals ) def _create_argument_table(self): diff --git a/awscli/customizations/globalargs.py b/awscli/customizations/globalargs.py index 3af8e2c482f5..281c707a49b4 100644 --- a/awscli/customizations/globalargs.py +++ b/awscli/customizations/globalargs.py @@ -101,10 +101,6 @@ def resolve_cli_connect_timeout(parsed_args, session, **kwargs): def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): if not resolve_v2_debug_mode(parsed_args): return - url_params = [ - param for param in remaining_args - if param.startswith('http://') or param.startswith('https://') - ] region = parsed_args.region or session.get_config_variable('region') s3_config = session.get_config_variable('s3') if ( @@ -180,17 +176,6 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): 'cliv2-migration-changes.html#cliv2-migration-ecr-get-login.\n', out_file=sys.stderr ) - if url_params and session.get_scoped_config().get('cli_follow_urlparam', True): - uni_print( - 'AWS CLI v2 UPGRADE WARNING: For input parameters that have ' - 'a prefix of http:// or https://, AWS CLI v2 will no longer ' - 'automatically request the content of the URL for the ' - 'parameter, and the `cli_follow_urlparam` option has been ' - 'removed. See https://docs.aws.amazon.com/cli/latest/' - 'userguide/cliv2-migration-changes.html' - '#cliv2-migration-paramfile.\n', - out_file=sys.stderr - ) for working, obsolete in HIDDEN_ALIASES.items(): working_split = working.split('.') working_service = working_split[0] diff --git a/awscli/paramfile.py b/awscli/paramfile.py index 14cd7fc49330..c07d67c21247 100644 --- a/awscli/paramfile.py +++ b/awscli/paramfile.py @@ -10,6 +10,8 @@ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF # ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. +import sys + import copy import logging import os @@ -20,6 +22,7 @@ from awscli import argprocess from awscli.compat import compat_open +from awscli.utils import resolve_v2_debug_mode logger = logging.getLogger(__name__) @@ -166,7 +169,7 @@ def __init__(self, prefixes=None): prefixes.update(REMOTE_PREFIX_MAP) self._prefixes = prefixes - def __call__(self, event_name, param, value, **kwargs): + def __call__(self, event_name, param, value, parsed_globals, **kwargs): """Handler that supports param values from URIs.""" cli_argument = param qualified_param_name = '.'.join(event_name.split('.')[1:]) @@ -175,13 +178,25 @@ def __call__(self, event_name, param, value, **kwargs): ): return else: - return self._check_for_uri_param(cli_argument, value) + return self._check_for_uri_param(cli_argument, value, parsed_globals) - def _check_for_uri_param(self, param, value): + def _check_for_uri_param(self, param, value, parsed_globals): if isinstance(value, list) and len(value) == 1: value = value[0] try: - return get_paramfile(value, self._prefixes) + param_file = get_paramfile(value, self._prefixes) + if param_file is not None and resolve_v2_debug_mode(parsed_globals): + print( + 'AWS CLI v2 UPGRADE WARNING: For input parameters that ' + 'have a prefix of http:// or https://, AWS CLI v2 will ' + 'not automatically request the content of the URL for the ' + 'parameter, and the `cli_follow_urlparam` option has been ' + 'removed. See https://docs.aws.amazon.com/cli/latest/' + 'userguide/cliv2-migration-changes.html' + '#cliv2-migration-paramfile.\n', + file=sys.stderr, + ) + return param_file except ResourceLoadingError as e: raise argprocess.ParamError(param.cli_name, str(e)) From 46eee3c96ecddec7475ee3ee83f975adef1e5584 Mon Sep 17 00:00:00 2001 From: aemous Date: Mon, 8 Dec 2025 11:07:53 -0500 Subject: [PATCH 2/5] Add more spacing around upgrade warnings. --- awscli/clidriver.py | 2 +- awscli/customizations/cloudformation/deploy.py | 2 +- awscli/customizations/globalargs.py | 16 ++++++++-------- awscli/customizations/paginate.py | 2 +- awscli/customizations/s3/subcommands.py | 2 +- awscli/customizations/scalarparse.py | 2 +- awscli/paramfile.py | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/awscli/clidriver.py b/awscli/clidriver.py index 83c83bae23e9..495f01aa2b14 100644 --- a/awscli/clidriver.py +++ b/awscli/clidriver.py @@ -694,7 +694,7 @@ def _detect_binary_file_migration_change( ] if arg_values_to_check: print( - 'AWS CLI v2 UPGRADE WARNING: When specifying a blob-type ' + '\nAWS CLI v2 UPGRADE WARNING: When specifying a blob-type ' 'parameter, AWS CLI v2 will assume the parameter value is ' 'base64-encoded. To maintain v1 behavior after upgrading ' 'to v2, set the `cli_binary_format` configuration ' diff --git a/awscli/customizations/cloudformation/deploy.py b/awscli/customizations/cloudformation/deploy.py index e33b03a8f362..c305cc3d2380 100644 --- a/awscli/customizations/cloudformation/deploy.py +++ b/awscli/customizations/cloudformation/deploy.py @@ -333,7 +333,7 @@ def deploy(self, deployer, stack_name, template_str, try: if v2_debug and fail_on_empty_changeset: uni_print( - 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, ' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, ' 'deploying an AWS CloudFormation Template that ' 'results in an empty changeset will NOT result in an ' 'error. You can add the -–no-fail-on-empty-changeset ' diff --git a/awscli/customizations/globalargs.py b/awscli/customizations/globalargs.py index 281c707a49b4..156bc29cb782 100644 --- a/awscli/customizations/globalargs.py +++ b/awscli/customizations/globalargs.py @@ -108,7 +108,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): == '' and 'AWS_PAGER' not in os.environ ): uni_print( - 'AWS CLI v2 UPGRADE WARNING: By default, the AWS CLI version 2 ' + '\nAWS CLI v2 UPGRADE WARNING: By default, the AWS CLI version 2 ' 'returns all output through your operating system’s default pager ' 'program. To retain AWS CLI v1 behavior after upgrading to AWS ' 'CLI v2, set the `cli_pager` configuration setting, or the ' @@ -120,7 +120,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): if 'PYTHONUTF8' in os.environ or 'PYTHONIOENCODING' in os.environ: if 'AWS_CLI_FILE_ENCODING' not in os.environ: uni_print( - 'AWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and ' + '\nAWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and ' 'PYTHONIOENCODING environment variables are unsupported ' 'in AWS CLI v2. AWS CLI v2 uses the `AWS_CLI_FILE_ENCODING` ' 'variable instead; set this environment variable to retain ' @@ -148,7 +148,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): ) if session.get_config_variable('api_versions'): uni_print( - 'AWS CLI v2 UPGRADE WARNING: The AWS CLI v2 does not support ' + '\nAWS CLI v2 UPGRADE WARNING: The AWS CLI v2 does not support ' 'calling earlier versions of AWS service APIs via the ' '`api_versions` configuration file setting. To migrate to v2 ' 'behavior, remove the `api_versions` configuration setting, and ' @@ -159,7 +159,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): ) if session.full_config.get('plugins', {}): uni_print( - 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, plugin support ' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, plugin support ' 'is provisional. If you rely on plugins, be sure to lock into ' 'a particular version of the AWS CLI and test the ' 'functionality of your plugins for each upgrade. See ' @@ -170,7 +170,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): ) if parsed_args.command == 'ecr' and remaining_args[0] == 'get-login': uni_print( - 'AWS CLI v2 UPGRADE WARNING: The `ecr get-login` command has ' + '\nAWS CLI v2 UPGRADE WARNING: The `ecr get-login` command has ' 'been removed in AWS CLI v2. You must use `ecr get-login-password` ' 'instead. See https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html#cliv2-migration-ecr-get-login.\n', @@ -187,7 +187,7 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): and f"--{working_param}" in remaining_args ): uni_print( - 'AWS CLI v2 UPGRADE WARNING: You have entered command ' + '\nAWS CLI v2 UPGRADE WARNING: You have entered command ' 'arguments that uses at least 1 of 21 hidden aliases that ' 'were removed in AWS CLI v2. You must replace usage of the ' 'obsolete alias with the corresponding working parameter. See ' @@ -215,7 +215,7 @@ def warn_if_east_configured_global_endpoint(request, operation_name, **kwargs): # from botocore, we check the endpoint URL directly. if 's3.amazonaws.com' in request.url: uni_print( - 'AWS CLI v2 UPGRADE WARNING: When you configure AWS CLI v2 ' + '\nAWS CLI v2 UPGRADE WARNING: When you configure AWS CLI v2 ' 'to use the `us-east-1` region, it uses the true regional ' 'endpoint rather than the global endpoint. To retain AWS CLI v1 ' 'behavior after upgrading to AWS CLI v2, configure the `region` ' @@ -234,7 +234,7 @@ def warn_if_sigv2( ): if context.get('auth_type', None) == 'v2': uni_print( - 'AWS CLI v2 UPGRADE WARNING: The AWS CLI v2 only uses Signature ' + '\nAWS CLI v2 UPGRADE WARNING: The AWS CLI v2 only uses Signature ' 'v4 to authenticate Amazon S3 requests. To migrate to AWS CLI ' 'v2 behavior, configure the Signature Version S3 setting to ' 'version 4. See https://docs.aws.amazon.com/cli/latest/userguide/' diff --git a/awscli/customizations/paginate.py b/awscli/customizations/paginate.py index 2d64bae611c3..86802f21efb6 100644 --- a/awscli/customizations/paginate.py +++ b/awscli/customizations/paginate.py @@ -304,7 +304,7 @@ def check_should_enable_pagination_call_parameters( ] if pagination_params_in_input_tokens: uni_print( - 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, if you specify ' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, if you specify ' 'pagination parameters by using a file with the ' '`--cli-input-json` parameter, automatic pagination will be ' 'turned off. To retain AWS CLI v1 behavior after upgrading to ' diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index b05ae1857020..7fb8c6047c59 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -1060,7 +1060,7 @@ def run(self): if self.parameters['v2_debug']: if operation_name == 'copy': uni_print( - 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, object ' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, object ' 'properties will be copied from the source in multipart ' 'copies between S3 buckets. This may result in extra S3 ' 'API calls being made. Breakage may occur if the principal ' diff --git a/awscli/customizations/scalarparse.py b/awscli/customizations/scalarparse.py index c5217a0db804..3211f9f0a2fa 100644 --- a/awscli/customizations/scalarparse.py +++ b/awscli/customizations/scalarparse.py @@ -88,7 +88,7 @@ def identity_with_warning(x): if not encountered_timestamp: encountered_timestamp = True uni_print( - 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, all timestamp ' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, all timestamp ' 'response values are returned in the ISO 8601 format. To ' 'migrate to v2 behavior, set the configuration variable ' '`cli_timestamp_format` to `iso8601`. See https://' diff --git a/awscli/paramfile.py b/awscli/paramfile.py index c07d67c21247..4ac85193473e 100644 --- a/awscli/paramfile.py +++ b/awscli/paramfile.py @@ -187,7 +187,7 @@ def _check_for_uri_param(self, param, value, parsed_globals): param_file = get_paramfile(value, self._prefixes) if param_file is not None and resolve_v2_debug_mode(parsed_globals): print( - 'AWS CLI v2 UPGRADE WARNING: For input parameters that ' + '\nAWS CLI v2 UPGRADE WARNING: For input parameters that ' 'have a prefix of http:// or https://, AWS CLI v2 will ' 'not automatically request the content of the URL for the ' 'parameter, and the `cli_follow_urlparam` option has been ' From cab30332be5c66c91915fa61da16fdadf4ae2814 Mon Sep 17 00:00:00 2001 From: aemous Date: Mon, 8 Dec 2025 11:24:00 -0500 Subject: [PATCH 3/5] Update tests based on changes to function interfaces. --- awscli/customizations/commands.py | 3 ++- tests/unit/test_argprocess.py | 6 +++--- tests/unit/test_clidriver.py | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/awscli/customizations/commands.py b/awscli/customizations/commands.py index 45ac54e565ff..8bec7017731a 100644 --- a/awscli/customizations/commands.py +++ b/awscli/customizations/commands.py @@ -154,7 +154,8 @@ def __call__(self, args, parsed_globals): 'custom', self.name, cli_argument, - value + value, + parsed_globals ) # If this parameter has a schema defined, then allow plugins diff --git a/tests/unit/test_argprocess.py b/tests/unit/test_argprocess.py index e59eb6c3b64c..e37398d82145 100644 --- a/tests/unit/test_argprocess.py +++ b/tests/unit/test_argprocess.py @@ -80,7 +80,7 @@ def test_uri_param(self): ) f.write(json_argument) f.flush() - result = self.uri_param('event-name', p, 'file://%s' % f.name) + result = self.uri_param('event-name', p, 'file://%s' % f.name, mock.Mock()) self.assertEqual(result, json_argument) def test_uri_param_no_paramfile_false(self): @@ -90,7 +90,7 @@ def test_uri_param_no_paramfile_false(self): json_argument = json.dumps([{"Name": "instance-id", "Values": ["i-1234"]}]) f.write(json_argument) f.flush() - result = self.uri_param('event-name', p, 'file://%s' % f.name) + result = self.uri_param('event-name', p, 'file://%s' % f.name, mock.Mock()) self.assertEqual(result, json_argument) def test_uri_param_no_paramfile_true(self): @@ -100,7 +100,7 @@ def test_uri_param_no_paramfile_true(self): json_argument = json.dumps([{"Name": "instance-id", "Values": ["i-1234"]}]) f.write(json_argument) f.flush() - result = self.uri_param('event-name', p, 'file://%s' % f.name) + result = self.uri_param('event-name', p, 'file://%s' % f.name, mock.Mock()) self.assertEqual(result, None) diff --git a/tests/unit/test_clidriver.py b/tests/unit/test_clidriver.py index bfc17cf71ab8..b70920e2c2f9 100644 --- a/tests/unit/test_clidriver.py +++ b/tests/unit/test_clidriver.py @@ -543,6 +543,7 @@ def test_custom_arg_paramfile(self, mock_handler): param=mock.ANY, service_name='ec2', value='file:///foo', + parsed_globals=mock.ANY, ) # Make sure it was called with our passed-in URI self.assertEqual( @@ -572,6 +573,7 @@ def test_custom_command_paramfile(self, mock_handler): param=mock.ANY, service_name='custom', value='file:///foo', + parsed_globals=mock.ANY, ) def test_custom_arg_no_paramfile(self): From 5972faebcea7159f9b8e28ff0cdf56f4ff7e6d13 Mon Sep 17 00:00:00 2001 From: aemous Date: Tue, 9 Dec 2025 19:14:42 -0500 Subject: [PATCH 4/5] Update wordings for each warning. --- awscli/clidriver.py | 14 +-- .../customizations/cloudformation/deploy.py | 17 ++-- awscli/customizations/globalargs.py | 88 +++++++++++-------- awscli/customizations/paginate.py | 4 +- awscli/customizations/s3/subcommands.py | 13 +-- awscli/customizations/scalarparse.py | 13 +-- awscli/paramfile.py | 12 +-- 7 files changed, 93 insertions(+), 68 deletions(-) diff --git a/awscli/clidriver.py b/awscli/clidriver.py index 495f01aa2b14..81429090fdc8 100644 --- a/awscli/clidriver.py +++ b/awscli/clidriver.py @@ -694,13 +694,15 @@ def _detect_binary_file_migration_change( ] if arg_values_to_check: print( - '\nAWS CLI v2 UPGRADE WARNING: When specifying a blob-type ' - 'parameter, AWS CLI v2 will assume the parameter value is ' - 'base64-encoded. To maintain v1 behavior after upgrading ' - 'to v2, set the `cli_binary_format` configuration ' + '\nAWS CLI v2 UPGRADE WARNING: When specifying a ' + 'blob-type parameter, AWS CLI v2 will assume the ' + 'parameter value is base64-encoded. This is different ' + 'from v1 behavior, where the AWS CLI will automatically ' + 'encode the value to base64. To retain v1 behavior in ' + 'AWS CLI v2, set the `cli_binary_format` configuration ' 'variable to `raw-in-base64-out`. See ' - 'https://docs.aws.amazon.com/cli/latest/userguide' - '/cliv2-migration-changes.html' + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html' '#cliv2-migration-binaryparam.\n', file=sys.stderr ) diff --git a/awscli/customizations/cloudformation/deploy.py b/awscli/customizations/cloudformation/deploy.py index c305cc3d2380..08a0a5647ae7 100644 --- a/awscli/customizations/cloudformation/deploy.py +++ b/awscli/customizations/cloudformation/deploy.py @@ -333,14 +333,15 @@ def deploy(self, deployer, stack_name, template_str, try: if v2_debug and fail_on_empty_changeset: uni_print( - '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, ' - 'deploying an AWS CloudFormation Template that ' - 'results in an empty changeset will NOT result in an ' - 'error. You can add the -–no-fail-on-empty-changeset ' - 'flag to migrate to v2 behavior and resolve this ' - 'warning. See https://docs.aws.amazon.com/cli/latest/' - 'userguide/cliv2-migration-changes.html' - '#cliv2-migration-cfn.\n', + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, deploying ' + 'an AWS CloudFormation Template that results in an empty ' + 'changeset will NOT result in an error by default. This ' + 'is different from v1 behavior, where empty changesets ' + 'result in an error by default. To migrate to v2 behavior ' + 'and resolve this warning, you can add the ' + '`--no-fail-on-empty-changeset` flag to the command. ' + 'See https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html#cliv2-migration-cfn.\n', out_file=sys.stderr ) result = deployer.create_and_wait_for_changeset( diff --git a/awscli/customizations/globalargs.py b/awscli/customizations/globalargs.py index 156bc29cb782..05ac1272bbb8 100644 --- a/awscli/customizations/globalargs.py +++ b/awscli/customizations/globalargs.py @@ -108,24 +108,26 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): == '' and 'AWS_PAGER' not in os.environ ): uni_print( - '\nAWS CLI v2 UPGRADE WARNING: By default, the AWS CLI version 2 ' - 'returns all output through your operating system’s default pager ' - 'program. To retain AWS CLI v1 behavior after upgrading to AWS ' - 'CLI v2, set the `cli_pager` configuration setting, or the ' + '\nAWS CLI v2 UPGRADE WARNING: By default, the AWS CLI v2 returns ' + 'all output through your operating system’s default pager ' + 'program. This is different from v1 behavior, where the system ' + 'pager is not used by default. To retain AWS CLI v1 behavior in ' + 'AWS CLI v2, set the `cli_pager` configuration setting, or the ' '`AWS_PAGER` environment variable, to the empty string. See ' - 'https://docs.aws.amazon.com/cli/latest/userguide' - '/cliv2-migration-changes.html#cliv2-migration-output-pager.\n', + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html#cliv2-migration-output-pager.\n', out_file=sys.stderr ) if 'PYTHONUTF8' in os.environ or 'PYTHONIOENCODING' in os.environ: if 'AWS_CLI_FILE_ENCODING' not in os.environ: uni_print( - '\nAWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and ' - 'PYTHONIOENCODING environment variables are unsupported ' - 'in AWS CLI v2. AWS CLI v2 uses the `AWS_CLI_FILE_ENCODING` ' - 'variable instead; set this environment variable to retain ' - 'AWS CLI v1 behavior after upgrading to AWS CLI v2. See ' - 'https://docs.aws.amazon.com/cli/latest/userguide/' + '\nThe AWS CLI v2 does not support The `PYTHONUTF8` and ' + '`PYTHONIOENCODING` environment variables, and instead uses ' + 'the `AWS_CLI_FILE_ENCODING` variable. This is different from ' + 'v1 behavior, where the former two variables are used ' + 'instead. To retain AWS CLI v1 behavior in AWS CLI v2, set ' + 'the `AWS_CLI_FILE_ENCODING` environment variable instead. ' + 'See https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html' '#cliv2-migration-encodingenvvar.\n', out_file=sys.stderr @@ -148,24 +150,28 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): ) if session.get_config_variable('api_versions'): uni_print( - '\nAWS CLI v2 UPGRADE WARNING: The AWS CLI v2 does not support ' - 'calling earlier versions of AWS service APIs via the ' - '`api_versions` configuration file setting. To migrate to v2 ' + '\nAWS CLI v2 UPGRADE WARNING: AWS CLI v2 UPGRADE WARNING: ' + 'The AWS CLI v2 does not support calling older versions of AWS ' + 'service APIs via the `api_versions` configuration file setting. This ' + 'is different from v1 behavior, where this configuration setting ' + 'can be used to pin older API versions. To migrate to v2 ' 'behavior, remove the `api_versions` configuration setting, and ' - 'test against the latest API versions. See ' + 'test against the latest service API versions. See ' 'https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html#cliv2-migration-api-versions.\n', out_file = sys.stderr ) if session.full_config.get('plugins', {}): uni_print( - '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, plugin support ' - 'is provisional. If you rely on plugins, be sure to lock into ' - 'a particular version of the AWS CLI and test the ' - 'functionality of your plugins for each upgrade. See ' - 'https://docs.aws.amazon.com/cli/latest/userguide/' - 'cliv2-migration-changes.html#' - 'cliv2-migration-profile-plugins\n', + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, plugins are ' + 'disabled by default, and support for plugins is provisional. ' + 'This is different from v1 behavior, where plugin support is URL ' + 'below to update your configuration to enable plugins in AWS CLI ' + 'v2. Also, be sure to lock into a particular version of the AWS ' + 'CLI and test the functionality of your plugins every time AWS ' + 'CLI v2 is upgraded. See https://docs.aws.amazon.com/cli/latest/' + 'userguide/cliv2-migration-changes.html' + '#cliv2-migration-profile-plugins.\n', out_file=sys.stderr ) if parsed_args.command == 'ecr' and remaining_args[0] == 'get-login': @@ -188,11 +194,12 @@ def detect_migration_breakage(parsed_args, remaining_args, session, **kwargs): ): uni_print( '\nAWS CLI v2 UPGRADE WARNING: You have entered command ' - 'arguments that uses at least 1 of 21 hidden aliases that ' - 'were removed in AWS CLI v2. You must replace usage of the ' - 'obsolete alias with the corresponding working parameter. See ' - 'https://docs.aws.amazon.com/cli/latest/userguide' - '/cliv2-migration-changes.html#cliv2-migration-aliases.\n', + 'arguments that use at least 1 of 21 built-in ("hidden") ' + 'aliases that were removed in AWS CLI v2. For this command ' + 'to work in AWS CLI v2, you must replace usage of the alias ' + 'with the corresponding parameter in AWS CLI v2. See ' + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html#cliv2-migration-aliases.\n', out_file=sys.stderr ) # Register against the provide-client-params event to ensure that the @@ -215,12 +222,14 @@ def warn_if_east_configured_global_endpoint(request, operation_name, **kwargs): # from botocore, we check the endpoint URL directly. if 's3.amazonaws.com' in request.url: uni_print( - '\nAWS CLI v2 UPGRADE WARNING: When you configure AWS CLI v2 ' - 'to use the `us-east-1` region, it uses the true regional ' - 'endpoint rather than the global endpoint. To retain AWS CLI v1 ' - 'behavior after upgrading to AWS CLI v2, configure the `region` ' - 'setting to `aws-global`. See https://docs.aws.amazon.com/cli' - '/latest/userguide/cliv2-migration-changes.html' + '\nAWS CLI v2 UPGRADE WARNING: When you configure AWS CLI v2 to ' + 'use the `us-east-1` region, it uses the true regional endpoint ' + 'rather than the global endpoint. This is different from v1 ' + 'behavior, where the global endpoint would be used when the ' + 'region is `us-east-1`. To retain AWS CLI v1 behavior in AWS ' + 'CLI v2, configure the region setting to `aws-global`. See ' + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html' '#cliv2-migration-s3-regional-endpoint.\n', out_file=sys.stderr ) @@ -235,10 +244,13 @@ def warn_if_sigv2( if context.get('auth_type', None) == 'v2': uni_print( '\nAWS CLI v2 UPGRADE WARNING: The AWS CLI v2 only uses Signature ' - 'v4 to authenticate Amazon S3 requests. To migrate to AWS CLI ' - 'v2 behavior, configure the Signature Version S3 setting to ' - 'version 4. See https://docs.aws.amazon.com/cli/latest/userguide/' - 'cliv2-migration-changes.html#cliv2-migration-sigv4\n', + 'v4 to authenticate Amazon S3 requests. This is different from ' + 'v1 behavior, where the signature used for Amazon S3 requests may ' + 'vary depending on configuration settings, region, and the ' + 'bucket being used. To migrate to AWS CLI v2 behavior, configure ' + 'the Signature Version S3 setting to version 4. See ' + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html#cliv2-migration-sigv4.\n', out_file=sys.stderr ) diff --git a/awscli/customizations/paginate.py b/awscli/customizations/paginate.py index 86802f21efb6..3bae390d7b18 100644 --- a/awscli/customizations/paginate.py +++ b/awscli/customizations/paginate.py @@ -307,7 +307,9 @@ def check_should_enable_pagination_call_parameters( '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, if you specify ' 'pagination parameters by using a file with the ' '`--cli-input-json` parameter, automatic pagination will be ' - 'turned off. To retain AWS CLI v1 behavior after upgrading to ' + 'turned off. This is different from v1 behavior, where ' + 'pagination parameters specified via the `--cli-input-json` ' + 'parameter are ignored. To retain AWS CLI v1 behavior in ' 'AWS CLI v2, remove all pagination parameters from the input ' 'JSON. See https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html' diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index 7fb8c6047c59..47ef10e88eec 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -1062,13 +1062,16 @@ def run(self): uni_print( '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, object ' 'properties will be copied from the source in multipart ' - 'copies between S3 buckets. This may result in extra S3 ' - 'API calls being made. Breakage may occur if the principal ' - 'does not have permission to call these extra APIs. This ' - 'warning cannot be resolved. See ' + 'copies between S3 buckets initiated via `aws s3` ' + 'commands, resulting in additional S3 API calls to ' + 'transfer the metadata. Note that the principal must ' + 'have permission to call these APIs, or the command may ' + 'fail. This is different from v1 behavior, where metadata ' + 'is not copied. For guidance on retaining v1 behavior in ' + 'AWS CLI v2, or for more details, see ' 'https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html' - '#cliv2-migration-s3-copy-metadata\n\n', + '#cliv2-migration-s3-copy-metadata.\n\n', out_file=sys.stderr ) diff --git a/awscli/customizations/scalarparse.py b/awscli/customizations/scalarparse.py index 3211f9f0a2fa..8ddf868b4984 100644 --- a/awscli/customizations/scalarparse.py +++ b/awscli/customizations/scalarparse.py @@ -88,11 +88,14 @@ def identity_with_warning(x): if not encountered_timestamp: encountered_timestamp = True uni_print( - '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, all timestamp ' - 'response values are returned in the ISO 8601 format. To ' - 'migrate to v2 behavior, set the configuration variable ' - '`cli_timestamp_format` to `iso8601`. See https://' - 'docs.aws.amazon.com/cli/latest/userguide/' + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, all ' + 'timestamp response values are returned in the ISO 8601 ' + 'format. This is different from v1 behavior, where the ' + 'timestamps are returned as they appear in the service ' + 'API response. To retain AWS CLI v1 behavior in AWS CLI ' + 'v2, set the configuration variable ' + '`cli_timestamp_format` to `wire`. See ' + 'https://docs.aws.amazon.com/cli/latest/userguide/' 'cliv2-migration-changes.html' '#cliv2-migration-timestamp.\n', out_file=sys.stderr diff --git a/awscli/paramfile.py b/awscli/paramfile.py index 4ac85193473e..baaa28f63150 100644 --- a/awscli/paramfile.py +++ b/awscli/paramfile.py @@ -188,11 +188,13 @@ def _check_for_uri_param(self, param, value, parsed_globals): if param_file is not None and resolve_v2_debug_mode(parsed_globals): print( '\nAWS CLI v2 UPGRADE WARNING: For input parameters that ' - 'have a prefix of http:// or https://, AWS CLI v2 will ' - 'not automatically request the content of the URL for the ' - 'parameter, and the `cli_follow_urlparam` option has been ' - 'removed. See https://docs.aws.amazon.com/cli/latest/' - 'userguide/cliv2-migration-changes.html' + 'have a prefix of `http://` or `https://`, AWS CLI v2 ' + 'will not automatically request the content of the URL ' + 'for the parameter, and the `cli_follow_urlparam` option ' + 'has been removed. For guidance on how to adapt this ' + 'command to AWS CLI v2 usage, see ' + 'https://docs.aws.amazon.com/cli/latest/userguide/' + 'cliv2-migration-changes.html' '#cliv2-migration-paramfile.\n', file=sys.stderr, ) From ebc837a54c8fdf5e74f7a067fd15a2483e28b010 Mon Sep 17 00:00:00 2001 From: aemous Date: Tue, 9 Dec 2025 19:37:51 -0500 Subject: [PATCH 5/5] Update tests based on updated wording in warnings. --- tests/functional/test_api_versions.py | 6 +++--- tests/unit/customizations/s3/test_subcommands.py | 9 ++++++--- tests/unit/customizations/test_globalargs.py | 12 ++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/functional/test_api_versions.py b/tests/functional/test_api_versions.py index e98f0159cb44..84748819b421 100644 --- a/tests/functional/test_api_versions.py +++ b/tests/functional/test_api_versions.py @@ -59,9 +59,9 @@ def test_v2_debug_migration_warning(self): # Make sure that the migration warning is printed since the user # specified --v2-debug self.assertIn( - 'AWS CLI v2 UPGRADE WARNING: The AWS CLI v2 does not support ' - 'calling earlier versions of AWS service APIs via the ' - '`api_versions` configuration file setting.', + 'AWS CLI v2 UPGRADE WARNING: AWS CLI v2 UPGRADE WARNING: The AWS ' + 'CLI v2 does not support calling older versions of AWS service ' + 'APIs via the `api_versions` configuration file setting.', stderr ) diff --git a/tests/unit/customizations/s3/test_subcommands.py b/tests/unit/customizations/s3/test_subcommands.py index b19d65a352ed..25fc257fcb21 100644 --- a/tests/unit/customizations/s3/test_subcommands.py +++ b/tests/unit/customizations/s3/test_subcommands.py @@ -635,9 +635,12 @@ def test_v2_debug_mv(self): cmd_arc.create_instructions() self.patch_make_request() cmd_arc.run() - warning_str = 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, object '\ - 'properties will be copied from the source in multipart '\ - 'copies between S3 buckets.' + warning_str = ( + 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, object ' + 'properties will be copied from the source in ' + 'multipart copies between S3 buckets initiated via ' + '`aws s3` commands' + ) output_str = f"(dryrun) move: {s3_file} to {s3_file}" self.assertIn(warning_str, self.err_output.getvalue()) self.assertIn(output_str, self.output.getvalue()) diff --git a/tests/unit/customizations/test_globalargs.py b/tests/unit/customizations/test_globalargs.py index bc4a09e09a92..d53438f5c095 100644 --- a/tests/unit/customizations/test_globalargs.py +++ b/tests/unit/customizations/test_globalargs.py @@ -253,9 +253,9 @@ def test_v2_debug_python_utf8_env_var(self): with capture_output() as output: globalargs.detect_migration_breakage(parsed_args, [], session) self.assertIn( - 'AWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and ' - 'PYTHONIOENCODING environment variables are unsupported ' - 'in AWS CLI v2.', + 'The AWS CLI v2 does not support The `PYTHONUTF8` and ' + '`PYTHONIOENCODING` environment variables, and instead ' + 'uses the `AWS_CLI_FILE_ENCODING` variable', output.stderr.getvalue() ) @@ -281,9 +281,9 @@ def test_v2_debug_python_io_encoding_env_var(self): with capture_output() as output: globalargs.detect_migration_breakage(parsed_args, [], session) self.assertIn( - 'AWS CLI v2 UPGRADE WARNING: The PYTHONUTF8 and ' - 'PYTHONIOENCODING environment variables are unsupported ' - 'in AWS CLI v2.', + 'The AWS CLI v2 does not support The `PYTHONUTF8` and ' + '`PYTHONIOENCODING` environment variables, and instead ' + 'uses the `AWS_CLI_FILE_ENCODING` variable', output.stderr.getvalue() )