aws-cli icon indicating copy to clipboard operation
aws-cli copied to clipboard

Doesn't handle ini files with UTF-8 Byte Order Mark (BOM)

Open MetalMichael opened this issue 8 years ago • 2 comments

System: Windows 10 Pro N x64 CLI Version: aws-cli/1.15.48 Python/2.7.14 Windows/10 botocore/1.10.48

Observed Result:

If ~/.aws/config or ~/aws/credentials are encoded with UTF-8-BOM then a ConfigParseError is given when running aws cli.

Traceback (most recent call last):
  File "C:\Python27\Scripts\aws.cmd", line 59, in <module>
    sys.exit(main())
  File "C:\Python27\Scripts\aws.cmd", line 55, in main
    return awscli.clidriver.main()
  File "C:\Users\Michael\AppData\Roaming\Python\Python27\site-packages\awscli\clidriver.py", line 58, in main
    driver = create_clidriver()
  File "C:\Users\Michael\AppData\Roaming\Python\Python27\site-packages\awscli\clidriver.py", line 68, in create_clidriver
    load_plugins(session.full_config.get('plugins', {}),
  File "C:\Users\Michael\AppData\Roaming\Python\Python27\site-packages\botocore\session.py", line 400, in full_config
    self._config = botocore.configloader.load_config(config_file)
  File "C:\Users\Michael\AppData\Roaming\Python\Python27\site-packages\botocore\configloader.py", line 106, in load_config
    parsed = raw_config_parse(config_filename)
  File "C:\Users\Michael\AppData\Roaming\Python\Python27\site-packages\botocore\configloader.py", line 152, in raw_config_parse
    path=_unicode_path(path))
botocore.exceptions.ConfigParseError: Unable to parse config file: C:\Users\Michael/.aws/config

Works as expected when using the same file with UTF-8 encoding, without byte order mark.

Expected Result:

aws-cli works regularly, and handles UTF-8-BOM encoded files.

Also likely the cause of issue #1778

MetalMichael avatar Jun 28 '18 22:06 MetalMichael

Traditionally what you would need to do is read the file using utf-8-sig as the encoding, but this wouldn't be a safe assumption for us to make as we would then be skipping out on the web of default encoding paths that python takes when you just call plain open. While we can't change the default encoding, we might be able to try it as a backup if normal reading fails.

JordonPhillips avatar Jul 02 '18 14:07 JordonPhillips

Greetings! It looks like this issue hasn’t been active in longer than one year. We encourage you to check if this is still an issue in the latest release. Because it has been longer than one year since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment to prevent automatic closure, or if the issue is already closed, please feel free to reopen it.

github-actions[bot] avatar Sep 18 '20 18:09 github-actions[bot]