The Python branch-creation port accepts an oversized `--number` and crashes at `int()` instead of rejecting it
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #5200 de @github-actions — fusionado
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Empieza con extensions/git/scripts/python/create_new_feature_branch.py, especialmente con la validación de --number alrededor de las líneas 107–116 y la conversión alrededor de la línea 532. Decide y aplica el máximo admitido antes de construir la rama; después, añade pruebas para el máximo y para un valor superior. La tarea estará hecha cuando una entrada demasiado grande termine limpiamente con un error de argumento en lugar de mostrar un traceback.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 144k
- Forks
- 12.9k
- Merge medio
- 1 d 7 h
- PR fusionados (30 d)
- 205
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/spec-kit
-
[Bug]: `create-new-feature.sh` rejects the feature descriptions `-n`, `-e` and `-E`, which the Python script acceptsPosiblemente ocupada @WOLIKIMCHENG la tomó hace 9 días. Abiertotriage-can-wait
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clashPosiblemente ocupada @chelsealong la tomó hace 10 días. Abiertotriage-must-have
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[Bug]: `specify preset set-priority` does not update agent command files that are already writtenPosiblemente ocupada @mikamikasuki la tomó hace 10 días. Abiertotriage-must-have
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Local config override file name differs between the docs (`<id>-config.local.yml`) and ConfigManager (`local-config.yml`)Posiblemente ocupada @gavenren la tomó hace 6 días. Abiertotriage-must-have
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
[Bug]: Extension alias conflict check misses spellings that map to the same file, so one extension overwrites and then deletes another's aliasPosiblemente ocupada @chelsealong la tomó hace 8 días. Abiertotriage-must-have
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de github/spec-kit
Issues similares
-
Backend issue lists report in-patch warnings and out-of-patch errors as not publishablePosiblemente ocupada @RaphaelFakhri la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
mozilla/code-review#3794 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Update docs that still describe the security registry as emptyPosiblemente ocupada @github-actions la tomó hoy. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
[Bug] adb backup script reports "Done" & exits 0 when the backup failsPosiblemente ocupada @bhattmanthan la tomó hoy. Abiertorequest-issue-assignment
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
OWASP/mastg#4034 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
agent-ui bug p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
amd/gaia#6580 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
correction metadata
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
acl-org/acl-anthology#10768 · 1 comentario ·
Los mantenedores suelen responder en 1 día