The Python branch-creation port accepts an oversized `--number` and crashes at `int()` instead of rejecting it
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia da extensions/git/scripts/python/create_new_feature_branch.py, in particolare dalla validazione di --number intorno alle righe 107–116 e dalla conversione intorno alla riga 532. Decidi e applica il valore massimo supportato prima di creare il branch, poi aggiungi test per il valore massimo e per uno superiore. Il lavoro è completato quando un input troppo grande termina correttamente con un errore di argomento invece di un traceback.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The Python branch-creation port accepts an oversized --number and crashes at int() instead of rejecting it
Project: github/spec-kit
Affected snapshot: 1c799bda6c136fcf42fb3475a922ccaac57e6c71
Summary
create_new_feature_branch.py validates --number only with the regular expression [0-9]+. A digit string longer than Python's integer-string conversion limit passes that check, but int(branch_number) later raises ValueError before any branch is created. The CLI reports an uncaught traceback instead of rejecting the value as out of domain.
Expected behavior
--number should be a bounded non-negative integer. An out-of-range value should produce the existing argument error (for example Error: --number must be a non-negative integer) and exit cleanly before branch construction.
Actual behavior
The regex accepts the 5,000-digit string. At feature_num = f"{int(branch_number):03d}", Python raises:
ValueError: Exceeds the limit (4300 digits) for integer string conversion
The command aborts with a traceback before git checkout.
Root cause
extensions/git/scripts/python/create_new_feature_branch.py:
- lines 107-116:
--numberis checked only byre.fullmatch(r"[0-9]+", args.branch_number). - line 532:
feature_num = f"{int(branch_number):03d}".
A digit string is not a bounded integer. The parser accepts values that the runtime cannot convert, and the conversion is not guarded.
Impact
- A normal CLI invocation with a malformed but syntactically numeric
--numbercrashes with an uncaught traceback instead of a user-facing error. - The feature-branch command aborts before creating or checking out the branch, leaving the caller with a partial/opaque failure.
- Automated callers that pre-validate
--numberwith the documented "non-negative integer" rule can still crash the tool.
Suggested fix
Bound the accepted value before conversion, for example:
if not re.fullmatch(r"[0-9]{1,9}", args.branch_number):
_err("Error: --number must be a non-negative integer")
raise SystemExit(1)
or keep the regex and wrap the conversion:
try:
feature_num = f"{int(branch_number):03d}"
except ValueError:
_err("Error: --number is outside the supported range")
raise SystemExit(1)
Define the supported maximum explicitly and test both the maximum and a value above it.
- Lingua principale
- Python
- Stelle
- 144k
- Fork
- 12.9k
- Merge medio
- 1g 4h
- PR unite (30g)
- 181
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un 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 github/spec-kit
-
bundle catalog add rewrites Windows drive paths as POSIX pathsForse già presa @chelsealong l’ha presa 1 giorno fa. Apertatriage-must-have
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Cline extension and preset commands have `speckit.*.md` file names rewritten to `speckit-*-md`Forse già presa @kevin9327 l’ha presa 4 giorni fa. Apertatriage-can-wait
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `create-new-feature.sh` rejects the feature descriptions `-n`, `-e` and `-E`, which the Python script acceptsForse già presa @WOLIKIMCHENG l’ha presa 7 giorni fa. Apertatriage-can-wait
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clashForse già presa @chelsealong l’ha presa 8 giorni fa. Apertatriage-must-have
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: `specify preset set-priority` does not update agent command files that are already writtenForse già presa @mikamikasuki l’ha presa 8 giorni fa. Apertatriage-must-have
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di github/spec-kit
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
pytest-dev/pyfakefs#1367 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
IFEvalG exclude_word_harder misses the keyword next to punctuation, at the start or end of the text, and in other letter caseForse già presa @damienen l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
allenai/open-instruct#2151 ·
I maintainer di solito rispondono entro 1 giorno
-
feat(plan): support convertorLabels and convertorAffinity in Plan resourceForse già presa @AmenB l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
RedHatQE/openshift-python-wrapper#2849 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 25 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
libnativeapi/nativeapi#21 ·