Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws s3 cp without recursive can produce a useless error message #2929

Closed
ghost opened this issue Oct 29, 2017 · 14 comments
Closed

aws s3 cp without recursive can produce a useless error message #2929

ghost opened this issue Oct 29, 2017 · 14 comments
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made.

Comments

@ghost
Copy link

ghost commented Oct 29, 2017

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

See https://twitter.com/lampholder/status/835777466685927424 (which is now one of the top results when googling the error message).

Invalid length for parameter Key, value: 0, valid range: 1-inf when you leave off --recursive is not a useful error message when it should either

  • Remind you to use --recursive

or

  • Act on only the files in the current working directory
@dstufft dstufft added enhancement closing-soon This issue will automatically close in 4 days unless further comments are made. and removed enhancement labels Oct 30, 2017
@dstufft
Copy link
Contributor

dstufft commented Oct 30, 2017

I can't reproduce this using awscli 1.11.178 and you seem to be quite a few versions behind. When I try to run a similar command I get:

upload failed: local/ to s3://bucket/remote/ [Errno 21] Is a directory: 'path/to/local/'

Could you try upgrading your version of aws-cli and see if you're able to still reproduce this error? Thanks!

@kyleknap
Copy link
Contributor

kyleknap commented Nov 6, 2017

Closing due to inactivity. Please open a new issue if you are able to give reproduction steps with the latest version of the CLI.

@kyleknap kyleknap closed this as completed Nov 6, 2017
@williford
Copy link

I get that error message when trying to cp a directory to the root of the bucket with aws-cli/1.14.57 (Python/3.5.2 Linux/4.13.0-36-generic botocore/1.9.10).

To reproduce:

$aws s3 cp test-dir s3://bucket/ --storage-class STANDARD_IA
upload failed: test-dir/ to s3://bucket/ Parameter validation failed:
Invalid length for parameter Key, value: 0, valid range: 1-inf

If a non-root directory is given, I get the error:

upload failed: test-dir/ to s3://bucket/path [Errno 21] Is a directory: '/absolute/path/to/test-dir/'

Both error messages should indicate that directories are omitted and that '--recursive' should be used. I suggest:

upload failed: test-dir/ to s3://bucket/path [Errno 21] Is a directory: '/absolute/path/to/test-dir/' (requires '--recursive')

@cblanto7
Copy link

cblanto7 commented Apr 1, 2018

getting this bug as well using aws-cli/1.14.9 Python/2.7.13 Linux/4.9.85-38.58.amzn1.x86_64 botocore/1.8.13 and just as the original poster suggested, use of --recursive fixes it and it works normally.

aws s3 cp "snapshot/" s3://juniper-backup-bucket this only outputs this error message: Invalid length for parameter Key, value: 0, valid range: 1-inf

aws s3 cp "snapshot/" s3://juniper-backup-bucket --recursive this one works as desired and copies the directory over to my bucket.

@artjomsimon
Copy link

Please reopen. As a new AWS user, running into that error and googling the error message leads users to this ticket.
This Developer Experience can be optimized a lot.

@vdemario
Copy link

I've just ran into this error in a brand new environment on CircleCI.

$ aws --version
aws-cli/1.15.79 Python/3.7.0 Linux/4.4.0-130-generic botocore/1.10.78

The base image is circleci/python:3.7, this is the full config, with a few paths changed:

    docker:
      - image: circleci/python:3.7
    steps:
      - checkout
      - run:
          name: Install awscli
          command: sudo pip install awscli
      - run:
          name: Configure awscli
          command: |
            aws configure set aws_access_key_id $AWS_ACCESS_KEY
            aws configure set aws_secret_access_key $AWS_SECRET_KEY
            aws configure set region us-east-2
      - run:
          name: Deploy
          command: aws s3 cp website/public s3://mybucket

I ssh'd into this environment, the dir path was valid and the aws s3 cp command failed with

upload failed: (redacted) Parameter validation failed:
Invalid length for parameter Key, value: 0, valid range: 1-inf
Exited with code 1

Running the command again with --recursive succeeded. Since I'm running pip install on a brand new environment I suppose this is the latest version of awscli. This should be more than enough to reproduce the error, please reopen.

@williford
Copy link

I think @kyleknap wants a new issue to be opened if this is ever going to be fixed.

@nicbou
Copy link

nicbou commented Sep 1, 2018

I found this GitHub ticket while googling the error message I got. I agree that it's completely useless. You really need to Google the message to even get an idea of what's wrong.

@MarcoLotz
Copy link

MarcoLotz commented Nov 22, 2018

The default that comes on

brew install awscli

provides the not really descriptive error described above.

@ghost
Copy link

ghost commented Feb 16, 2020

I got the same error while trying to run an s3 cp with the source being a local directory which was empty. I was accidental pointing at the wrong dir but the error message was non descriptive.

@naikus
Copy link

naikus commented Apr 30, 2020

I got this error because i wasn't using --recursive option:

download failed: s3://test/platfom/utterances/ to lib/conversation/utterances/ [Errno 20] Not a directory: '/opt/bot/lib/conversation/utterances/.F11a5Fae' -> '/opt/bot/lib/conversation/utterances/'

@vlad88sv
Copy link

vlad88sv commented Jan 6, 2021

Thank you for this, I didn't know --recursive was required to copy a folder, the error message is useless.

@msfasha
Copy link

msfasha commented Jul 23, 2021

aws s3 cp --recursive local_folder s3://mybucketname/path

similarly, deleting all bucket content
aws s3 rm --recursive local_folder s3://mybucketname/

thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this issue Feb 12, 2022
@sunemGil
Copy link

Buenas tardes, e revisado los comentarios pero en mi caso me dice que no se pueden encontrar las credenciales, este es el comando que estoy usando:
aws s3 cp C:\Modulo1 s3://carpetadearchivospdf --recursive

Este es el error que me marca:
upload failed: ....\Modulo1\pdf1.pdf to s3://carpetadearchivospdf/pdf1.pdf Unable to locate credentials

¿alguien que me auxile por favor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closing-soon This issue will automatically close in 4 days unless further comments are made.
Projects
None yet
Development

No branches or pull requests