The Python branch-creation port accepts an oversized `--number` and crashes at `int()` instead of rejecting it
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #5200 của @github-actions — đã merge
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 84/100
Hướng nghiên cứu
Bắt đầu với extensions/git/scripts/python/create_new_feature_branch.py, đặc biệt là phần xác thực --number quanh các dòng 107–116 và phần chuyển đổi quanh dòng 532. Hãy xác định và áp dụng giới hạn tối đa được hỗ trợ trước khi tạo branch, sau đó thêm các bài kiểm tra cho giá trị tối đa và một giá trị vượt quá giới hạn đó. Hoàn thành khi đầu vào quá lớn thoát gọn với lỗi đối số thay vì traceback.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 144k
- Fork
- 12.9k
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 205
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/spec-kit
-
[Bug]: `create-new-feature.sh` rejects the feature descriptions `-n`, `-e` and `-E`, which the Python script acceptsCó thể đã có người làm @WOLIKIMCHENG đã nhận 9 ngày trước. Đang mởtriage-can-wait
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: `bundle init <bundle>` initialises with the default integration instead of the bundle's, then aborts with a clashCó thể đã có người làm @chelsealong đã nhận 10 ngày trước. Đang mởtriage-must-have
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: `specify preset set-priority` does not update agent command files that are already writtenCó thể đã có người làm @mikamikasuki đã nhận 10 ngày trước. Đang mởtriage-must-have
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Local config override file name differs between the docs (`<id>-config.local.yml`) and ConfigManager (`local-config.yml`)Có thể đã có người làm @gavenren đã nhận 6 ngày trước. Đang mởtriage-must-have
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Extension alias conflict check misses spellings that map to the same file, so one extension overwrites and then deletes another's aliasCó thể đã có người làm @chelsealong đã nhận 8 ngày trước. Đang mởtriage-must-have
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của github/spec-kit
Issue tương tự
-
DBFS append mode silently overwrites existing filesCó thể đã có người làm @IlyaKhalafi đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
fsspec/filesystem_spec#2429 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Retrieval rerank fallback statistics stay zero after provider failureCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
volcengine/OpenViking#7014 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fedora-copr/copr#4600 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ansys/pydpf-core#3620 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày