The Python branch-creation port accepts an oversized `--number` and crashes at `int()` instead of rejecting it
Mantenedores costumam responder em até 1 dia
Um pull request relacionado já foi integrado.
- #5200 de @github-actions — integrado
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 84/100
Direção de pesquisa
Comece por extensions/git/scripts/python/create_new_feature_branch.py, especialmente pela validação de --number por volta das linhas 107–116 e pela conversão por volta da linha 532. Decida e aplique o valor máximo aceito antes de construir a branch; em seguida, adicione testes para o valor máximo e para um valor acima dele. O trabalho estará concluído quando uma entrada grande demais terminar corretamente com um erro de argumento, em vez de exibir um traceback.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Python
- Estrelas
- 144k
- Forks
- 12.9k
- Merge médio
- 1d 7h
- PRs com merge (30d)
- 205
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de github/spec-kit
-
[Bug]: `create-new-feature.sh` rejects the feature descriptions `-n`, `-e` and `-E`, which the Python script acceptsTalvez já em andamento @WOLIKIMCHENG assumiu há 9 dias. Abertatriage-can-wait
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clashTalvez já em andamento @chelsealong assumiu há 10 dias. Abertatriage-must-have
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: `specify preset set-priority` does not update agent command files that are already writtenTalvez já em andamento @mikamikasuki assumiu há 10 dias. Abertatriage-must-have
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: Local config override file name differs between the docs (`<id>-config.local.yml`) and ConfigManager (`local-config.yml`)Talvez já em andamento @gavenren assumiu há 6 dias. Abertatriage-must-have
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
[Bug]: Extension alias conflict check misses spellings that map to the same file, so one extension overwrites and then deletes another's aliasTalvez já em andamento @chelsealong assumiu há 8 dias. Abertatriage-must-have
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
Todas as issues de github/spec-kit
Issues semelhantes
-
DBFS append mode silently overwrites existing filesTalvez já em andamento @IlyaKhalafi assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
fsspec/filesystem_spec#2429 ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: Retrieval rerank fallback statistics stay zero after provider failureTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
volcengine/OpenViking#7014 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
fedora-copr/copr#4600 ·
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
ansys/pydpf-core#3620 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia