From c4d2682504069ab59c18daec2e7a555d7bd81742 Mon Sep 17 00:00:00 2001 From: shreyaskommuri Date: Tue, 12 May 2026 14:28:28 -0700 Subject: [PATCH] Add MD5 to checksum-algorithm choices for s3 commands MD5 is a valid checksum algorithm for S3 operations but was missing from the --checksum-algorithm choices list, causing the CLI to reject it with an invalid choice error before the request was made. This change adds MD5 to the accepted choices alongside the other supported algorithms (CRC32, SHA256, SHA1, etc.). Companion fix in botocore registers the Md5Checksum implementation so the checksum is computed correctly at the request layer. Fixes aws/aws-cli#10295 Generated by AI tools, and reviewed by shreyaskommuri --- awscli/customizations/s3/subcommands.py | 2 +- tests/unit/customizations/s3/test_subcommands.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/awscli/customizations/s3/subcommands.py b/awscli/customizations/s3/subcommands.py index bd3f60f16479..aed4a8a4f414 100644 --- a/awscli/customizations/s3/subcommands.py +++ b/awscli/customizations/s3/subcommands.py @@ -459,7 +459,7 @@ } CHECKSUM_ALGORITHM = { - 'name': 'checksum-algorithm', 'choices': ['CRC64NVME', 'CRC32', 'SHA256', 'SHA1', 'CRC32C', 'SHA512', 'XXHASH64', 'XXHASH3', 'XXHASH128'], + 'name': 'checksum-algorithm', 'choices': ['CRC64NVME', 'CRC32', 'SHA256', 'SHA1', 'CRC32C', 'SHA512', 'XXHASH64', 'XXHASH3', 'XXHASH128', 'MD5'], 'help_text': 'Indicates the algorithm used to create the checksum for the object.' } diff --git a/tests/unit/customizations/s3/test_subcommands.py b/tests/unit/customizations/s3/test_subcommands.py index 82d85bf6a25f..2389f8f7d25e 100644 --- a/tests/unit/customizations/s3/test_subcommands.py +++ b/tests/unit/customizations/s3/test_subcommands.py @@ -753,6 +753,14 @@ def test_validate_checksum_algorithm_download_error(self): cmd_params.add_paths(paths) self.assertIn('Expected checksum-algorithm parameter to be used with one of following path formats', cm.msg) + def test_validate_checksum_algorithm_md5_upload(self): + paths = [self.file_creator.rootdir, 's3://bucket/key'] + parameters = {'checksum_algorithm': 'MD5'} + cmd_params = CommandParameters('cp', parameters, '') + cmd_params.add_paths(paths) + self.assertEqual(cmd_params.parameters['checksum_algorithm'], 'MD5') + + def test_validate_checksum_algorithm_sync_download_error(self): paths = ['s3://bucket/key', self.file_creator.rootdir] parameters = {'checksum_algorithm': 'CRC32C'}