aws configure set s3.* can raise UnboundLocalError when updating nested config blocks
I maintainer di solito rispondono entro 2 giorni
@fallintoplace ci sta già lavorando.
Dal 24/5/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da awscli/customizations/configure/writer.py, in particolare da ConfigFileWriter._update_subattributes(), e rivedi i casi esistenti in tests/unit/customizations/configure/test_writer.py. Esegui i test del writer e aggiungi la copertura per blocchi annidati vuoti, commenti e un'intestazione di sezione immediata; il lavoro è completato quando l'aggiornamento di s3.signature_version non genera più errori e preserva la configurazione annidata prevista.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
aws configure set s3.signature_version s3v4 can crash when the target config already has a nested s3 = block and the next line is not another option line.
I reproduced this with all of the following existing config shapes:
- an empty nested block
- a comment immediately after
s3 = - an immediate next section header after
s3 =
The crash comes from ConfigFileWriter._update_subattributes() reading current_indent even when OPTION_REGEX did not match the current line.
Regression Issue
This does not look like a recent regression. git blame shows _update_subattributes() was introduced with this behavior in 9c2fd8098a.
Expected Behavior
Updating a nested config value should append or update the nested key without crashing.
For example, starting from:
[default]
s3 =
# comment
addressing_style = path
setting s3.signature_version should produce:
[default]
s3 =
# comment
addressing_style = path
signature_version = s3v4
Current Behavior
An uncaught traceback is raised:
Traceback (most recent call last):
File "/Users/hoangvu/Code/OSS/aws-cli/awscli/customizations/configure/writer.py", line 115, in update_config
self._update_section_contents(contents, section_name, new_values)
File "/Users/hoangvu/Code/OSS/aws-cli/awscli/customizations/configure/writer.py", line 203, in _update_section_contents
j = self._update_subattributes(
File "/Users/hoangvu/Code/OSS/aws-cli/awscli/customizations/configure/writer.py", line 231, in _update_subattributes
if starting_indent == current_indent or \
^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'current_indent' where it is not associated with a value
Reproduction Steps
Minimal reproducer:
from awscli.customizations.configure.writer import ConfigFileWriter
import os
import tempfile
fd, path = tempfile.mkstemp()
os.close(fd)
with open(path, "w") as f:
f.write("[default]\ns3 =\n# comment\n addressing_style = path\n")
ConfigFileWriter().update_config(
{"__section__": "default", "s3": {"signature_version": "s3v4"}},
path,
)
This also reproduces with:
[default]
s3 =
and:
[default]
s3 =
[profile other]
region = us-east-1
Possible Solution
Handle non-option lines before comparing indentation, or initialize current_indent safely.
For example, _update_subattributes() could skip lines where OPTION_REGEX does not match, while still treating a new section header as the boundary for inserting new nested values.
It would also be helpful to add regression tests in tests/unit/customizations/configure/test_writer.py for:
- empty nested blocks
- comments after
s3 = - section headers immediately after
s3 =
Additional Information/Context
I reproduced this against the current develop checkout:
aws-cli/1.45.14develop@b698a6a77- macOS 26.5 arm64
- Python 3.13.2
The user-facing path appears to be aws configure set s3.signature_version ..., but the minimal reproducer above avoids unrelated environment/setup dependencies.
CLI version used
aws-cli/1.45.14
Environment details (OS name and version, etc.)
macOS 26.5 arm64, Python 3.13.2
- Lingua principale
- Python
- Stelle
- 17.4k
- Fork
- 4.8k
- Merge medio
- 4g 3h
- PR unite (30g)
- 64
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-cli
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
feature-request login p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws/aws-cli#10739 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
aws history show/list: UnboundLocalError instead of clear error when pager fails to startForse già presa @Adityaj0 l’ha presa 85 giorni fa. Apertaneeds-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
CodeArtifact login: auth token leaked unredacted in CommandFailedError via subprocess stderrForse già presa @PANYAMHEMANTH l’ha presa 7 giorni fa. Apertacodeartifact login investigating p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
Refactor: drop redundant list() wrapper around sorted() in formatter.py/text.pyForse già presa @Adityaj0 l’ha presa 88 giorni fa. Apertafeature-request p3
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
aws/aws-cli#10568 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
Issue simili
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
gke-labs/kube-agents#5671 ·
I maintainer di solito rispondono entro 1 giorno
-
docs(auth): Method B step 4 should tell users to tick "Use this client for an AI-powered agent"Apertadocumentation next-release v0.9.6
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
khuisman/mcp-gee-sweet#1446 ·
I maintainer di solito rispondono entro 1 giorno
-
In-box secret files written before their chmod: lc-creds, stacks tee, and the workspace tokenApertamodel:sonnet runtime:claude security size:S
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
FootprintAI/Containarium#3671 ·
I maintainer di solito rispondono entro 1 giorno
-
HolidayBase: reassigning `language` does not re-initialize translations or re-populate holidaysForse già presa @shikhabhadoria l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vacanza/holidays#4116 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug CLI exec
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno