diff --git a/botocore/httpchecksum.py b/botocore/httpchecksum.py index db78057e5d..2fab60c56e 100644 --- a/botocore/httpchecksum.py +++ b/botocore/httpchecksum.py @@ -250,7 +250,14 @@ def resolve_request_checksum_algorithm( supported_algorithms = _SUPPORTED_CHECKSUM_ALGORITHMS algorithm_name = params[algorithm_member].lower() - if algorithm_name not in supported_algorithms: + if algorithm_name == "crc32c" and not HAS_CRT: + raise FlexibleChecksumError( + error_msg=( + "Using CRC32C requires an additional dependency. You will " + "need to pip install botocore[crt] before proceeding." + ) + ) + elif algorithm_name not in supported_algorithms: raise FlexibleChecksumError( error_msg="Unsupported checksum algorithm: %s" % algorithm_name ) diff --git a/tests/unit/test_httpchecksum.py b/tests/unit/test_httpchecksum.py index f5550e3542..e103b97a54 100644 --- a/tests/unit/test_httpchecksum.py +++ b/tests/unit/test_httpchecksum.py @@ -14,6 +14,7 @@ from io import BytesIO from botocore.awsrequest import AWSResponse +from botocore.compat import HAS_CRT from botocore.exceptions import AwsChunkedWrapperError, FlexibleChecksumError from botocore.httpchecksum import ( _CHECKSUM_CLS, @@ -172,6 +173,22 @@ def test_request_checksum_algorithm_model_unsupported_algorithm(self): request, operation_model, params, supported_algorithms=[] ) + @unittest.skipIf(HAS_CRT, "Error only expected when CRT is not available") + def test_request_checksum_algorithm_model_no_crt_crc32c_unsupported(self): + request = self._build_request(b"") + operation_model = self._make_operation_model( + http_checksum={"requestAlgorithmMember": "Algorithm"}, + ) + params = {"Algorithm": "crc32c"} + with self.assertRaises(FlexibleChecksumError) as context: + resolve_request_checksum_algorithm( + request, operation_model, params + ) + self.assertIn( + "Using CRC32C requires an additional dependency", + str(context.exception), + ) + def test_request_checksum_algorithm_model_legacy_md5(self): request = self._build_request(b"") operation_model = self._make_operation_model(required=True)