Skip to content

Fix nested configure set subattribute updates#10349

Open
fallintoplace wants to merge 1 commit into
aws:developfrom
fallintoplace:fix/configure-nested-block-unboundlocal
Open

Fix nested configure set subattribute updates#10349
fallintoplace wants to merge 1 commit into
aws:developfrom
fallintoplace:fix/configure-nested-block-unboundlocal

Conversation

@fallintoplace
Copy link
Copy Markdown

Summary

Fix nested aws configure set updates so subattribute writes stop cleanly at section and indentation boundaries instead of crashing or rewriting same-indent sibling keys.

Fixes #10348.

Root cause

ConfigFileWriter._update_subattributes() read current_indent even when the current line did not match OPTION_REGEX, which caused an UnboundLocalError for empty nested blocks, comments, and immediate section headers.

The helper also evaluated nested-key updates before confirming that an option line was still inside the nested block, which let same-indent sibling keys get rewritten incorrectly.

What changed

  • treat section headers as an immediate nested-block boundary
  • skip non-option lines safely while scanning nested blocks
  • stop at same-indent sibling options before attempting nested-key updates
  • add regression tests for empty nested blocks, comment lines, immediate section headers, and same-indent sibling keys

Validation

  • PYTHONPATH=/Users/hoangvu/Code/OSS/aws-cli /tmp/awscli-verify/bin/python -m pytest -q tests/unit/customizations/configure/test_writer.py

@fallintoplace fallintoplace marked this pull request as ready for review May 24, 2026 09:44
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.

aws configure set s3.* can raise UnboundLocalError when updating nested config blocks

1 participant