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

improve error message in case of file not found #9295

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions awscli/argprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,18 @@ def unpack_scalar_cli_arg(argument_model, value, cli_name=''):
):
file_path = os.path.expandvars(value)
file_path = os.path.expanduser(file_path)
if not os.path.isfile(file_path):
msg = 'Blob values must be a path to a file.'
is_file = os.path.isfile(file_path)
if not is_file:
is_dir = os.path.isdir(file_path)
exists = os.path.exists(file_path)
absolute = os.path.abspath(file_path)
# Print details about the file path supplied to help to determine that was the problem.
msg = (f'Blob values must be a path to a file. '
f'Input path: {file_path}. '
f'Absolute: {absolute}. '
f'Exists: {exists}. '
f'Is directory: {is_dir}. '
f'Is file: {is_file}')
raise ParamError(cli_name, msg)
return open(file_path, 'rb')
elif argument_model.type_name == 'boolean':
Expand Down