aws / aws-cli

Universal Command Line Interface for Amazon Web Services
Other
15.54k stars 4.12k forks source link

Error uploading empty file: "seek() takes 2 positional arguments but 3 were given" #2403

Closed ajdavis closed 3 years ago

ajdavis commented 7 years ago

awscli version "1.11.13-1ubuntu1~16.04.0" was installed with the Ubuntu package manager and run like:

aws s3 cp doc/html s3://BUCKET/PATH/HERE --recursive --acl public-read --region us-east-1

It successfully uploads all the files in the source directory except for one zero-byte file. It fails there with:

seek() takes 2 positional arguments but 3 were given
kyleknap commented 7 years ago

I was not able to reproduce the issue with that version of the CLI. I have a feeling it may be with how the CLI got packaged for Ubuntu. Unfortunately, we do not maintain those methods of installation. So I am not sure what may be causing the issue. These are the methods that we do maintain: http://docs.aws.amazon.com/cli/latest/userguide/installing.html. Do you get the same issue when you use pip or the bundled installer?

ixodie commented 7 years ago

I am having a similar issue.

aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-59-generic botocore/1.4.70 (ubuntu 16.04)

I do:

aws s3 sync /mnt/ebs-volume/image/ s3://xxx-my-images

And I get a TON of messages like this: upload failed: image/xxx/xxx/xxx.jpg to s3://xxx-my-images/xxx/xxx//xxx.jpg seek() takes 2 positional arguments but 3 were given

So I cannot really be sure that the images are being uploaded/synced properly.

JordonPhillips commented 7 years ago

@kyleknap I wonder what version of requests is being used. This looks like the same kind of error that you'll get if you try to use the latest version of requests, and I know Ubuntu un-bundles our vendored version in favor of their version.

ixodie commented 7 years ago

I can troubleshoot here if you tell me what to look at.

I should point out that I am getting that message on non-zero length files as well.

ctrlrsf commented 7 years ago

I was seeing these errors with awscli installed from Ubuntu 16.04 package. Worked around it by installing awscli with pip. See below for version differences. Note, awscli from Ubuntu is running on python 3.5 and awscli I installed with pip is actually python 2.7.

$ dpkg -l | grep aws
ii  awscli                              1.11.13-1ubuntu1~16.04.0            all          Universal Command Line Environment for AWS

# Ubuntu version:
$ aws --version
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-45-generic botocore/1.4.70

# pip install awscli version:
$ ~/.local/bin/aws --version
aws-cli/1.11.44 Python/2.7.12 Linux/4.4.0-45-generic botocore/1.5.7
ixodie commented 7 years ago

Worked like a charm. Thanks!

omervk commented 7 years ago

As long as the tool only supports Python 2, there should be an error when trying to use Python 3.

liwo commented 7 years ago

I just created a bug report with ubuntu to let the package maintainers know about the issue. Maybe they can sort this out?

https://bugs.launchpad.net/ubuntu/+source/awscli/+bug/1696800

nlebas commented 7 years ago

I've had the same problem when trying to upload an open file. The data had not been flushed to disk, yet. Closing my file before uploading it solved the issue.

$ aws --version aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-1013-aws botocore/1.4.70

$ cat /etc/os-release NAME="Ubuntu" VERSION="16.04.3 LTS (Xenial Xerus)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 16.04.3 LTS" VERSION_ID="16.04" HOME_URL="http://www.ubuntu.com/" SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/" VERSION_CODENAME=xenial UBUNTU_CODENAME=xenial

Preen commented 6 years ago

still an issue on Ubuntu 16.04 LTS.

ASayre commented 6 years ago

Good Morning!

We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI.

This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports.

As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions.

We’ve imported existing feature requests from GitHub - Search for this issue there!

And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue.

GitHub will remain the channel for reporting bugs.

Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface

-The AWS SDKs & Tools Team

This entry can specifically be found on UserVoice at: https://aws.uservoice.com/forums/598381-aws-command-line-interface/suggestions/33168337-error-uploading-empty-file-seek-takes-2-positi

jamesls commented 6 years ago

Based on community feedback, we have decided to return feature requests to GitHub issues.

aerostitch commented 6 years ago

So if you start debugging a minimum (because we're in 2018 and saying "use python2" is really lame) using:

$ aws --debug s3 cp /tmp/bla s3://my-bucket/bla

You get something that looks like:

efc2ebbbbc0c01db31c7f42e23d4a3c094f91f78bf1caf56710be7d436f4c559
2018-05-15 14:46:00,184 - ThreadPoolExecutor-0_0 - botocore.auth - DEBUG - Signature:
ed7af55076ae84ac2c26bab35bfc0a856113caa84577e7f7972d9ccf6ddf6a32
2018-05-15 14:46:00,184 - ThreadPoolExecutor-0_0 - botocore.hooks - DEBUG - Event request-created.s3.PutObject: calling handler <function signal_transferring at 0x7f2ab9123d90>
2018-05-15 14:46:00,184 - ThreadPoolExecutor-0_0 - s3transfer.tasks - DEBUG - Exception raised.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/s3transfer/tasks.py", line 126, in __call__
    return self._execute_main(kwargs)
  File "/usr/lib/python3/dist-packages/s3transfer/tasks.py", line 150, in _execute_main
    return_value = self._main(**kwargs)
  File "/usr/lib/python3/dist-packages/s3transfer/upload.py", line 692, in _main
    client.put_object(Bucket=bucket, Key=key, Body=body, **extra_args)
  File "/usr/lib/python3/dist-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python3/dist-packages/botocore/client.py", line 599, in _make_api_call
    operation_model, request_dict)
  File "/usr/lib/python3/dist-packages/botocore/endpoint.py", line 148, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/lib/python3/dist-packages/botocore/endpoint.py", line 173, in _send_request
    request = self.create_request(request_dict, operation_model)
  File "/usr/lib/python3/dist-packages/botocore/endpoint.py", line 158, in create_request
    prepared_request = self.prepare_request(request)
  File "/usr/lib/python3/dist-packages/botocore/endpoint.py", line 169, in prepare_request
    return request.prepare()
  File "/usr/lib/python3/dist-packages/botocore/awsrequest.py", line 371, in prepare
    p.prepare_body(self.data, self.files)
  File "/usr/lib/python3/dist-packages/botocore/awsrequest.py", line 442, in prepare_body
    data.seek(0, 2)
TypeError: seek() takes 2 positional arguments but 3 were given

And there you see that the element you are trying to seek on is a s3transfer.utils.ReadFileChunk which does have only 1 argument (outside of self): https://github.com/boto/s3transfer/blob/master/s3transfer/utils.py#L470 So either botocore needs to be patched to change the logic https://github.com/boto/botocore/blob/develop/botocore/awsrequest.py#L441 or s3transfer needs to support seek with 3 args.

aerostitch commented 6 years ago

A patch is actually already proposed in s3transfert via: https://github.com/boto/s3transfer/pull/88 and https://github.com/boto/s3transfer/pull/102

dhruveshsheladiya commented 6 years ago

Try installing awscli from pip which is the suggested/supported way of doing so: http://docs.aws.amazon.com/cli/latest/userguide/installing.html

KES777 commented 5 years ago

I have same issue. But I upload zero length files first time.

Second try get me errors

dbnicholson commented 5 years ago

The issue occurs when using the s3transfer library with python3. I fixed this in boto/s3transfer#102 10 months ago. Please review that and merge it.

AndrewPomorski commented 5 years ago

I am having the same issue when running sync in a CircleCI build job (Ubuntu 14.04) and the cli is installed from apt repository. I was not able to reproduce that problem in my dev environment (OSX Mojave 10.14.1), where the cli I'm using has been downloaded from aws' website.

cristianrat commented 5 years ago

Having this issue as well, right now. Running out of a container (Ubuntu) Installed from repository as well.

walked commented 5 years ago

Also running into this. Problematic

cptcanuck commented 5 years ago

I ran into this. My file was empty. Once I put contents in the file the same command worked. 😖

# touch test
# aws s3 cp test s3://bucket
upload failed: ./test to s3://bucket seek() takes 2 positional arguments but 3 were given
# echo "test" > test
# aws s3 cp test s3://bucket
upload: ./test to s3://bucket
# aws --version
aws-cli/1.11.13 Python/3.5.2 Linux/4.4.0-1075-aws botocore/1.4.70
zoran commented 5 years ago

same here

MichaelChirico commented 5 years ago

Just got hit by the same. Adding garbage to the test file fixed it.

dbnicholson commented 5 years ago

@kyleknap @jamesls can we please change the labels on this issue? This is not a feature request, it's a bug in the published AWS code. If you agree that the AWS python SDK supports python 3 (which I think you should since the official python 2 EOL is only a few months away), then this is simply a bug in part of the SDK and the fix that I generated from @kylenap's feedback over a year ago should be reviewed. I'm also happy to write a test for aws-cli that highlights this error here.

If, on the other hand, you think that supporting python 3 is a feature, then I'm happy to add code that turns loading on python 3 into a failure or a documentation patch that shows that python 3 is not officially supported. Then at least the distros wouldn't try to package aws-cli using python 3.

Can something change, please? This has been in a broken state for over a year and clearly affects a lot of people. Thanks.

hheennrryy21 commented 4 years ago

Zero byte file also failed using AWS CLI

seek() takes 2 positional arguments but 3 were given

akx commented 4 years ago

:+1:, still seeing this. Uploading zero byte file fails.

darrynten commented 4 years ago

Still happening to us too...

Yay for not syncing .gitkeep files

dsmurrell commented 4 years ago

AWS wants their lunch eaten by other cloud providers it seems.

aidenmitchell commented 4 years ago

Still a problem.

taikedz commented 4 years ago

I was getting this too (on Mint 19), decided to hunt down to try and fix it myself.

Eventually figured out that this is due to using outdated awscli from distros' repositories.

Remove your distro's version (and ensure python3-botocore is removed in the process), and install with sudo pip install awscli

This is a distro problem, the core issue was fixed long ago...

nateprewitt commented 3 years ago

Yesterday we were able to merge boto/s3transfer#102 and released s3transfer 0.3.7. This version should include an implementation of seek much closer to the standard library and fix a handful of other failures states ReadFileChunk may have previously encountered.

If you're still experiencing issues, they should be resolved by installing the latest version of s3transfer (>=0.3.7). Anyone installing the AWS CLI on a new system or using pip install --upgrade awscli should get this update automatically. We'll leave this issue open for the next few days for any further feedback and plan on resolving it at the end of the week. Thanks everyone!

github-actions[bot] commented 3 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.