You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The Python branch-creation port accepts an oversized --number and crashes at int() instead of rejecting it #5194
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.
Issue author @soarkit reports that extensions/git/scripts/python/create_new_feature_branch.py accepts very large digit-only --number values, then crashes when converting to int(). Expected behavior is a clean argument error; actual behavior is a traceback with ValueError: Exceeds the limit (4300 digits) for integer string conversion.
No additional issue comments were present at assessment time.
Symptom
When --number is a very long numeric string (e.g., 5000 digits), argument parsing accepts it as "non-negative integer", but branch-number formatting later raises an uncaught ValueError and aborts execution. Expected behavior is deterministic validation failure with a user-facing CLI error and exit code 1, without traceback.
Reproduction
Invoke create_new_feature_branch.py with --number set to a digit-only value above Python’s integer string conversion limit (e.g., '9' * 5000) and a valid description.
Observe that parse-time validation passes ([0-9]+), then execution reaches int(branch_number) and fails.
[NEEDS CLARIFICATION: reporter environment details (exact Python runtime/version and invocation wrapper) were not included beyond the error text.]
Suspected Code Paths
extensions/git/scripts/python/create_new_feature_branch.py:113-115 — --number validation only checks regex r"[0-9]+", which enforces character class but not numeric bounds.
extensions/git/scripts/python/create_new_feature_branch.py:532 — feature_num = f"{int(branch_number):03d}" performs unguarded conversion and can raise ValueError for oversized numeric strings.
tests/extensions/git/test_git_extension.py:657-667 — negative-number rejection is covered, but this does not exercise oversized positive numeric strings.
tests/extensions/git/test_git_extension_python_parity.py:297-300 — explicit-number happy path (42) exists; no oversized-number regression case observed.
Root Cause Hypothesis
The Python extension script conflates “all characters are digits” with “value is safely representable and within accepted domain.” The parse-time validator permits arbitrarily long decimal strings, but the later conversion assumes convertibility. Python enforces a maximum digit length for integer conversion and raises ValueError when exceeded; because this path is not caught and mapped to a user error, the CLI emits traceback-style failure. Confidence: high.
Proposed Remediation
Preferred: Add explicit bounded integer validation for --number before branch formatting, mirroring the core scripts/python/create_new_feature.py pattern (_MAX_FEATURE_NUMBER = 2**63 - 1 and length/lexical bound check). Then convert only after validation succeeds. Keep error messaging consistent and user-facing (no traceback).
Concretely, in the extension Python script: (a) validate digits, (b) enforce max supported value, (c) return/exit with clear Error: --number must be between 0 and <max>, got '<value>' when out of range, and (d) optionally keep a narrow defensive try/except ValueError around conversion as a final guard.
Alternatives (optional):
Catch ValueError only at conversion site and emit an out-of-range error. Trade-off: works for this crash, but leaves domain rules implicit and less testable than a dedicated validator.
Add regression test passing an oversized digit-only --number and assert clean error (no traceback) + nonzero exit.
Add boundary tests at max accepted value and max+1 for the extension path.
Add parity assertion (bash vs python extension) for oversized --number behavior, or explicitly codify intended divergence if not shared.
Risks & Considerations
Behavior change in validation/error text can affect snapshot/parity tests; update expected messages intentionally.
If extension scripts are intended to stay behaviorally aligned across bash/powershell/python, equivalent bound handling should be considered in all twins to avoid new parity drift.
Ensure branch auto-detection paths (where number is computed internally) still behave identically and do not regress on large existing prefixes.
Open Questions
[NEEDS CLARIFICATION: What numeric upper bound should be canonical for extension scripts (match core at 2**63 - 1 vs extension-specific bound)?]
[NEEDS CLARIFICATION: Should extension error wording align with core script wording exactly for cross-command consistency?]
Summary: the Python extension now bounds --number to 0..2**63-1 before conversion, so oversized digit-only inputs fail with a clean validation error instead of crashing at int().
Next step: please review the draft PR; then run the stage-3 bug-test workflow to validate the fix if that stage is configured in this repository.
Activity
github-actions commentedon Oct 30, 2026
Bug assessment — oversized-number-crash: Valid · severity low
Bug Assessment: Oversized
--numbercrashes Python branch creation--numberand crashes atint()instead of rejecting it #5194Report (summarized)
Issue author @soarkit reports that
extensions/git/scripts/python/create_new_feature_branch.pyaccepts very large digit-only--numbervalues, then crashes when converting toint(). Expected behavior is a clean argument error; actual behavior is a traceback withValueError: Exceeds the limit (4300 digits) for integer string conversion.No additional issue comments were present at assessment time.
Symptom
When
--numberis a very long numeric string (e.g., 5000 digits), argument parsing accepts it as "non-negative integer", but branch-number formatting later raises an uncaughtValueErrorand aborts execution. Expected behavior is deterministic validation failure with a user-facing CLI error and exit code 1, without traceback.Reproduction
create_new_feature_branch.pywith--numberset to a digit-only value above Python’s integer string conversion limit (e.g.,'9' * 5000) and a valid description.[0-9]+), then execution reachesint(branch_number)and fails.[NEEDS CLARIFICATION: reporter environment details (exact Python runtime/version and invocation wrapper) were not included beyond the error text.]
Suspected Code Paths
extensions/git/scripts/python/create_new_feature_branch.py:113-115—--numbervalidation only checks regexr"[0-9]+", which enforces character class but not numeric bounds.extensions/git/scripts/python/create_new_feature_branch.py:532—feature_num = f"{int(branch_number):03d}"performs unguarded conversion and can raiseValueErrorfor oversized numeric strings.tests/extensions/git/test_git_extension.py:657-667— negative-number rejection is covered, but this does not exercise oversized positive numeric strings.tests/extensions/git/test_git_extension_python_parity.py:297-300— explicit-number happy path (42) exists; no oversized-number regression case observed.Root Cause Hypothesis
The Python extension script conflates “all characters are digits” with “value is safely representable and within accepted domain.” The parse-time validator permits arbitrarily long decimal strings, but the later conversion assumes convertibility. Python enforces a maximum digit length for integer conversion and raises
ValueErrorwhen exceeded; because this path is not caught and mapped to a user error, the CLI emits traceback-style failure. Confidence: high.Proposed Remediation
Preferred: Add explicit bounded integer validation for
--numberbefore branch formatting, mirroring the corescripts/python/create_new_feature.pypattern (_MAX_FEATURE_NUMBER = 2**63 - 1and length/lexical bound check). Then convert only after validation succeeds. Keep error messaging consistent and user-facing (no traceback).Concretely, in the extension Python script: (a) validate digits, (b) enforce max supported value, (c) return/exit with clear
Error: --number must be between 0 and <max>, got '<value>'when out of range, and (d) optionally keep a narrow defensivetry/except ValueErroraround conversion as a final guard.Alternatives (optional):
ValueErroronly at conversion site and emit an out-of-range error. Trade-off: works for this crash, but leaves domain rules implicit and less testable than a dedicated validator.Files likely to change:
extensions/git/scripts/python/create_new_feature_branch.pytests/extensions/git/test_git_extension.pytests/extensions/git/test_git_extension_python_parity.pyTests to add or update:
--numberand assert clean error (no traceback) + nonzero exit.--numberbehavior, or explicitly codify intended divergence if not shared.Risks & Considerations
Open Questions
2**63 - 1vs extension-specific bound)?]Fix oversized-number-crash: bound Python --number parsing
github-actions commentedon Oct 30, 2026
Pull request created: #5200
github-actions commentedon Oct 30, 2026
Draft PR proposed for oversized-number-crash from branch
fix/5194-oversized-number-crash: https://github.com/github/spec-kit/pulls?q=is:pr+head:fix%2F5194-oversized-number-crashSummary: the Python extension now bounds
--numberto0..2**63-1before conversion, so oversized digit-only inputs fail with a clean validation error instead of crashing atint().Next step: please review the draft PR; then run the stage-3 bug-test workflow to validate the fix if that stage is configured in this repository.