Repository: aws/aws-cli

Issue:
Exception thrown if uploaded file size > 5TB
We recently hit an exception when uploading a large file that by the looks of it should instead be reported to the user as a helpful message. The exception is being raised attempting to create that helpful message.

Version: aws-cli/1.10.11 Python/2.7.9 Windows/2012Server botocore/1.4.2

on: create_warning() got an unexpected keyword argument 'message' 
Traceback (most recent call last): 
File "awscli\customizations\s3\s3handler.pyc", line 99, in call 
File "awscli\customizations\s3\s3handler.pyc", line 186, in _enqueue_tasks 
TypeError: create_warning() got an unexpected keyword argument 'message'

Looks like it is happening here:

https://github.com/aws/aws-cli/blob/c5fb60e1b49667d6f689bb8f8670ed4a1c01791a/awscli/customizations/s3/s3handler.py#L185

I think message= should be error_message= (although I don't know Python, so could be reading it wrong.



Discussion:
Thanks for letting us know, we'll get that updated.


Resolving patch:
diff --git a/awscli/customizations/s3/s3handler.py b/awscli/customizations/s3/s3handler.py
--- a/awscli/customizations/s3/s3handler.py
+++ b/awscli/customizations/s3/s3handler.py
@@ -184,7 +184,7 @@ def _enqueue_tasks(self, files):
             if too_large and filename.operation_name == 'upload':
                 warning_message = "File exceeds s3 upload limit of 5 TB."
                 warning = create_warning(relative_path(filename.src),
-                                         message=warning_message)
+                                         warning_message)
                 self.result_queue.put(warning)
             # Warn and skip over glacier incompatible tasks.
             elif not self.params.get('force_glacier_transfer') and \


Test patch:
diff --git a/tests/unit/customizations/s3/test_s3handler.py b/tests/unit/customizations/s3/test_s3handler.py
--- a/tests/unit/customizations/s3/test_s3handler.py
+++ b/tests/unit/customizations/s3/test_s3handler.py
@@ -25,7 +25,7 @@
 from awscli.customizations.s3.fileinfo import FileInfo
 from awscli.customizations.s3.tasks import CreateMultipartUploadTask, \
     UploadPartTask, CreateLocalFileTask
-from awscli.customizations.s3.utils import MAX_PARTS
+from awscli.customizations.s3.utils import MAX_PARTS, MAX_UPLOAD_SIZE
 from awscli.customizations.s3.transferconfig import RuntimeConfig
 from tests.unit.customizations.s3 import make_loc_files, clean_loc_files, \
     MockStdIn, S3HandlerBaseTest
@@ -195,6 +195,28 @@ def test_upload_fail(self):
         stdout, stderr, rc = self.run_s3_handler(self.s3_handler, tasks)
         self.assertEqual(rc.num_tasks_failed, 1)
 
+    def test_max_size_limit(self):
+        """
+        This test verifies that we're warning on file uploads which are greater
+        than the max upload size (5TB currently).
+        """
+        tasks = [FileInfo(
+            src=self.loc_files[0],
+            dest=self.bucket + '/test1.txt',
+            compare_key=None,
+            src_type='local',
+            dest_type='s3',
+            operation_name='upload',
+            size=MAX_UPLOAD_SIZE+1,
+            last_update=None,
+            client=self.client
+        )]
+        self.parsed_responses = []
+        _, _, rc = self.run_s3_handler(self.s3_handler, tasks)
+        # The task should *warn*, not fail
+        self.assertEqual(rc.num_tasks_failed, 0)
+        self.assertEqual(rc.num_tasks_warned, 1)
+
     def test_multi_upload(self):
         """
         This test only checks that the multipart upload process works.