diff --git a/.changes/next-release/enhancement-Migration-87248.json b/.changes/next-release/enhancement-Migration-87248.json new file mode 100644 index 000000000000..88099af194ab --- /dev/null +++ b/.changes/next-release/enhancement-Migration-87248.json @@ -0,0 +1,5 @@ +{ + "type": "enhancement", + "category": "Migration", + "description": "Added support to upgrade debug mode for detecting breaking change introduced in AWS CLI v2: in v2, Cyclic Redundancy Check 64 (CRC64NVME) is used by default for ``aws s3`` commands that upload a file to S3, but Cyclic Redundancy Check 32 (CRC32) is used instead in v1. To use upgrade debug mode, specify the ``--v2-debug`` global parameter on a command." +} diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index 473293c6a3c0..494625a26c12 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -1144,6 +1144,24 @@ def run(self): '#cliv2-migration-s3-copy-metadata.\n\n', out_file=sys.stderr ) + elif ( + operation_name == 'upload' + and self.parameters.get('checksum_algorithm') is None + ): + uni_print( + '\nAWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for ' + '`aws s3` commands that upload a file to an S3 bucket, ' + 'Cyclic Redundancy Check 64 (CRC64NVME) will be used to ' + 'compute object checksums by default and include it in ' + 'the request. This is different from v1 behavior, where ' + 'Cyclic Redundancy Check 32 (CRC32) checksums will ' + 'instead be used. 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-checksums.\n\n', + out_file=sys.stderr + ) fgen_kwargs = { 'client': self._source_client, 'operation_name': operation_name, diff --git a/tests/functional/s3/test_cp_command.py b/tests/functional/s3/test_cp_command.py index d0243d657bd6..eb7b0c5603cc 100644 --- a/tests/functional/s3/test_cp_command.py +++ b/tests/functional/s3/test_cp_command.py @@ -817,6 +817,33 @@ def test_download_with_checksum_mode_crc32c(self): self.assertEqual(self.operations_called[1][0].name, 'GetObject') self.assertEqual(self.operations_called[1][1]['ChecksumMode'], 'ENABLED') + def test_upload_with_no_checksum_param_v2_debug(self): + full_path = self.files.create_file('foo.txt', 'contents') + cmdline = f'{self.prefix} {full_path} s3://bucket/key.txt --v2-debug' + _, stderr, _ = self.run_cmd(cmdline, expected_rc=0) + self.assertIn( + 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` ' + 'commands that upload a file to an S3 bucket, Cyclic Redundancy ' + 'Check 64 (CRC64NVME) will be used to compute object checksums by ' + 'default and include it in the request.', + stderr + ) + + def test_upload_with_crc32_checksum_v2_debug(self): + full_path = self.files.create_file('foo.txt', 'contents') + cmdline = ( + f'{self.prefix} {full_path} s3://bucket/key.txt ' + f'--checksum-algorithm CRC32 --v2-debug' + ) + _, stderr, _ = self.run_cmd(cmdline, expected_rc=0) + self.assertNotIn( + 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` ' + 'commands that upload a file to an S3 bucket, Cyclic Redundancy ' + 'Check 64 (CRC64NVME) will be used to compute object checksums by ' + 'default and include it in the request.', + stderr + ) + class TestStreamingCPCommand(BaseAWSCommandParamsTest): def test_streaming_upload(self): diff --git a/tests/functional/s3/test_mv_command.py b/tests/functional/s3/test_mv_command.py index b7e6ca71ed63..4e7b6dc5f839 100644 --- a/tests/functional/s3/test_mv_command.py +++ b/tests/functional/s3/test_mv_command.py @@ -165,6 +165,33 @@ def test_download_with_checksum_mode_crc32(self): self.assertEqual(self.operations_called[1][0].name, 'GetObject') self.assertEqual(self.operations_called[1][1]['ChecksumMode'], 'ENABLED') + def test_upload_with_no_checksum_param_v2_debug(self): + full_path = self.files.create_file('foo.txt', 'contents') + cmdline = f'{self.prefix} {full_path} s3://bucket/key.txt --v2-debug' + _, stderr, _ = self.run_cmd(cmdline, expected_rc=0) + self.assertIn( + 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` ' + 'commands that upload a file to an S3 bucket, Cyclic Redundancy ' + 'Check 64 (CRC64NVME) will be used to compute object checksums by ' + 'default and include it in the request.', + stderr + ) + + def test_upload_with_crc32_checksum_v2_debug(self): + full_path = self.files.create_file('foo.txt', 'contents') + cmdline = ( + f'{self.prefix} {full_path} s3://bucket/key.txt ' + f'--checksum-algorithm CRC32 --v2-debug' + ) + _, stderr, _ = self.run_cmd(cmdline, expected_rc=0) + self.assertNotIn( + 'AWS CLI v2 UPGRADE WARNING: In AWS CLI v2, for `aws s3` ' + 'commands that upload a file to an S3 bucket, Cyclic Redundancy ' + 'Check 64 (CRC64NVME) will be used to compute object checksums by ' + 'default and include it in the request.', + stderr + ) + class TestMvCommandWithValidateSameS3Paths(BaseS3TransferCommandTest):