Skip to content

Commit

Permalink
improve error message in case of file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
imanushin committed Feb 12, 2025
1 parent fe720e1 commit 61e25ef
Showing 1 changed file with 12 additions and 2 deletions.
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

0 comments on commit 61e25ef

Please sign in to comment.