Skip to content

Handle UTF-8 BOM in config and credentials files - #10886

Open
KushagraIndurkhya wants to merge 1 commit into
aws:v2from
KushagraIndurkhya:fix/config-utf8-bom-10768
Open

KushagraIndurkhya wants to merge 1 commit into
aws:v2from
KushagraIndurkhya:fix/config-utf8-bom-10768

Conversation

@KushagraIndurkhya

Copy link
Copy Markdown

Issue #: #10768

Description of changes

When config or credentials files are saved with a UTF-8 Byte Order Mark (BOM: \xef\xbb\xbf, common on Windows editors such as Notepad), running CLI commands failed with Unable to parse config file because the first section header was parsed as \ufeff[section] instead of [section].

This change:

  1. Passes encoding='utf-8-sig' to cp.read([path], encoding='utf-8-sig') in raw_config_parse() in awscli/botocore/configloader.py. The utf-8-sig Python codec transparently strips the BOM marker if present while behaving identically to standard UTF-8 when absent.
  2. Applies to both config and credentials files loaded through raw_config_parse.
  3. Adds unit tests in tests/unit/botocore/test_configloader.py covering single config files, nested configs, multi-file loads with BOM, and credentials file BOM handling in tests/unit/botocore/test_credentials.py.
  4. Adds a changelog entry at .changes/next-release/config-utf8-bom.json.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@KushagraIndurkhya
KushagraIndurkhya requested a review from a team as a code owner November 11, 2026 20:42

This branch has not been deployed

No deployments
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