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

Clarify the error message when a file cannot be opened for reading #1341

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmbaturin
Copy link

When s3cmd cannot open a local file because the user has no permission to read it, it produces the following error message:

$ touch	test-file
$ sudo chmod root:root test-file
$ sudo chmod	600 test-file
$ s3cmd put ./file s3://some-bucket
ERROR: Upload of 'test-file' is not possible (Reason: Permission denied)

That message can mean two different things (at least to the user who doesn't see S3-side errors frequently): either the current user has no permission to read the file or the current AWS credentials do not permit its upload to the target bucket. When that happened to me lately, I spent a few minutes trying to figure out what was wrong with my AWS credentials before I realized that s3cmd is actually talking about the local file. :)

This PR changes the message to make it clear what actually happens:

$ ./s3cmd put test-file s3://some-bucket
ERROR: Upload of 'test-file' is not possible. Reason: failed to open the file for reading (Permission denied).

The failed to open the file for reading message is only prepended when io.open(filename_bytes, mode='rb') causes OSError or IOError, all other messages (special file, etc.) remain unchanged.

I took the liberty to change the format of the "Upload of ... is not possible" message to avoid nested parens there. If it's against your error message guidelines, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant