Skip to content

Treat empty config subsection values as empty dicts#3641

Open
norus wants to merge 1 commit intoboto:developfrom
norus:fix-empty-s3-config-subsection
Open

Treat empty config subsection values as empty dicts#3641
norus wants to merge 1 commit intoboto:developfrom
norus:fix-empty-s3-config-subsection

Conversation

@norus
Copy link

@norus norus commented Feb 27, 2026

Description

When a config file contains an empty subsection key such as s3 = with no value or indented block following it, the INI parser returns an empty string. Downstream code that calls .get('s3', {}).get(...) on the parsed config raises AttributeError because str has no .get() method, producing the cryptic message:

'str' object has no attribute 'get'

This error surfaces for any AWS CLI command, not just S3, because botocore checks the s3 config for dualstack endpoint settings during client construction.

Fix

In raw_config_parse(), when parse_subsections is enabled and a config value is an empty string, treat it as an empty dict {} rather than storing the raw empty string. This matches the logical meaning of an empty subsection block.

Reproduction

[default]
region=us-west-2
s3=
endpoint_url=http://localhost:1234/
$ aws sts get-caller-identity
'str' object has no attribute 'get'

After fix, the command proceeds normally (no config parse error for the empty s3 block).

Testing

  • Added test config file aws_config_nested_empty
  • Added test_nested_hierarchy_with_empty_subsection: verifies empty s3= produces {}
  • Added test_nested_hierarchy_empty_subsection_allows_get: verifies downstream .get() chain works
  • All 19 configloader tests pass

Fixes aws/aws-cli#9469

When a config file contains an empty subsection key such as 's3 ='
with no value or indented block following it, the INI parser returns
an empty string. Downstream code that calls .get('s3', {}).get(...)
on the parsed config raises AttributeError because str has no .get()
method, producing the cryptic message:

    'str' object has no attribute 'get'

This error surfaces for any AWS CLI command, not just S3, because
botocore checks the s3 config for dualstack endpoint settings during
client construction.

Treat empty string values as empty dicts when parse_subsections is
enabled, matching the logical meaning of an empty subsection block.

Fixes aws/aws-cli#9469
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.

Better error handling for s3 configuration blocks

1 participant