Skip to content

Improve error message for duplicate profile sections in config - #10885

Open
KushagraIndurkhya wants to merge 1 commit into
aws:v2from
KushagraIndurkhya:fix/config-duplicate-profile-9261
Open

KushagraIndurkhya wants to merge 1 commit into
aws:v2from
KushagraIndurkhya:fix/config-duplicate-profile-9261

Conversation

@KushagraIndurkhya

Copy link
Copy Markdown

Issue #: #9261

Description of changes

When ~/.aws/config contains duplicated profile sections, the parser caught configparser.DuplicateSectionError and re-raised a generic ConfigParseError(path=path) producing Unable to parse config file: <path> without indicating which profile was duplicated, the line numbers, or what went wrong.

This change:

  1. Enhances ConfigParseError to accept an optional message string rendered as:
    Unable to parse config file: <path> - <message> (preserving backwards compatibility and pickle roundtripping).
  2. Updates raw_config_parse to catch configparser.DuplicateSectionError, determine the duplicated section/profile name, and locate line numbers for both the first occurrence and the duplicate occurrence:
    Found duplicate profile 'xyz' (first seen on line 5, duplicated on line 20)
  3. Adds unit tests in tests/unit/botocore/test_configloader.py covering standard profiles, quoted profiles, default profile, and non-profile sections.
  4. Adds tests in tests/unit/botocore/test_exceptions.py verifying message formatting and pickle roundtrip compatibility.
  5. Adds a changelog entry at .changes/next-release/config-duplicate-profile-error.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