Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-configure-10587.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "configure",
"description": "Fixed an `UnboundLocalError` raised by `aws configure set` when updating a nested config section (e.g. `s3`, `s3api`) that currently has no sub-keys under it."
}
2 changes: 2 additions & 0 deletions awscli/customizations/configure/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def _update_section_contents(self, contents, section_name, new_values):

def _update_subattributes(self, index, contents, values, starting_indent):
index += 1
current_indent = None
i = index - 1
for i in range(index, len(contents)):
line = contents[i]
match = self.OPTION_REGEX.search(line)
Expand Down
28 changes: 28 additions & 0 deletions tests/unit/customizations/configure/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,34 @@ def test_updated_nested_attribute_new_section(self):
'[profile foo]\n'
'foo = bar\n')

def test_add_to_empty_nested_stanza_followed_by_section(self):
original = (
'[default]\n'
's3 =\n'
'[profile foo]\n'
'foo = bar\n'
)
self.assert_update_config(
original, {'__section__': 'default',
's3': {'signature_version': 'newval'}},
'[default]\n'
's3 =\n'
' signature_version = newval\n'
'[profile foo]\n'
'foo = bar\n')

def test_add_to_empty_nested_stanza_at_eof(self):
original = (
'[default]\n'
's3 =\n'
)
self.assert_update_config(
original, {'__section__': 'default',
's3': {'signature_version': 'newval'}},
'[default]\n'
's3 =\n'
' signature_version = newval\n')

def test_update_nested_attr_no_prior_nesting(self):
original = (
'[default]\n'
Expand Down