s3tools / s3cmd

Official s3cmd repo -- Command line tool for managing S3 compatible storage services (including Amazon S3 and CloudFront).
https://s3tools.org/s3cmd
GNU General Public License v2.0
4.54k stars 904 forks source link

Provide a human-friendly error message when invalid S3CMD_CONFIG variable is passed #1008

Open Nowaker opened 5 years ago

Nowaker commented 5 years ago

I set a custom variable in my CI. Unfortunately, the name I chose was S3CMD_CONFIG. I didn't know it was used by s3cmd. This cost me two hours of trying to find what was incorrect.

Please provide a human-friendly error message when S3CMD_CONFIG contains garbage (in s3cmd's eyes).

ghost commented 5 years ago

Unfortunately, the name I chose was S3CMD_CONFIG.

What else could one possibly expect with an environment flag namespaced like that?

fviard commented 5 years ago

Ah ah true! @Nowaker But that being said, currently i noticed a few wrong behaviors when config file or option are incorrect, like an incorrect error message. I have planned to rework that part of the code to fix that, and I hope that it would have the side effect to also fix your case.

Nowaker commented 5 years ago

@jhabdas An error message, if my stuff is incorrect in application's eyes. Compare s3cmd to kubectl:

[nowaker@nwkr-desktop ~]$ S3CMD_CONFIG=/tmp/blah s3cmd ls s3://blah
ERROR: S3 error: 403 (InvalidAccessKeyId): The AWS Access Key Id you provided does not exist in our records.
[nowaker@nwkr-desktop ~]$ kubectl --kubeconfig /tmp/blah get pods
error: stat /tmp/blah: no such file or directory

@fviard Thanks. I think a success story would be this behavior:

  1. If S3CMD_CONFIG env var is specified AND file doesn't exist, isn't readable, or has syntax errors, fail.
  2. If --config param is specified AND file doesn't exist, isn't readable, or has syntax errors, fail.
  3. If ~/.s3cfg file exists AND isn't readable, or has syntax errors, fail.