The Python branch-creation port accepts an oversized `--number` and crashes at `int()` instead of rejecting it
メンテナーはふだん 1 日以内に返信
関連するプルリクエストがすでにマージされています。
- #5200 @github-actions による — マージ済み
評価
調査の方向性
extensions/git/scripts/python/create_new_feature_branch.pyから始め、特に107~116行付近の--numberの検証と、532行付近の変換を確認します。ブランチの作成前にサポートする最大値を決定して適用し、その最大値と、それを超える値のテストを追加してください。大きすぎる入力がトレースバックではなく、引数エラーで正常に終了すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Python
- スター
- 144k
- フォーク
- 12.9k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 205
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/spec-kit のほかの issue
-
[Bug]: `create-new-feature.sh` rejects the feature descriptions `-n`, `-e` and `-E`, which the Python script accepts対応中かも @WOLIKIMCHENG が 9 日前に担当しました。 オープンtriage-can-wait
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clash対応中かも @chelsealong が 10 日前に担当しました。 オープンtriage-must-have
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: `specify preset set-priority` does not update agent command files that are already written対応中かも @mikamikasuki が 10 日前に担当しました。 オープンtriage-must-have
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Local config override file name differs between the docs (`<id>-config.local.yml`) and ConfigManager (`local-config.yml`)対応中かも @gavenren が 6 日前に担当しました。 オープンtriage-must-have
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Extension alias conflict check misses spellings that map to the same file, so one extension overwrites and then deletes another's alias対応中かも @chelsealong が 8 日前に担当しました。 オープンtriage-must-have
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
github/spec-kit の issue をすべて見る
似ている issue
-
DBFS append mode silently overwrites existing files対応中かも @IlyaKhalafi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
fsspec/filesystem_spec#2429 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Retrieval rerank fallback statistics stay zero after provider failure対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
volcengine/OpenViking#7014 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
fedora-copr/copr#4600 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pydpf-core#3620 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信