fix(powershell): stop create-new-feature.ps1 crashing on a description with no ASCII words - #4138
Open
jawwad-ali wants to merge 1 commit into
Open
fix(powershell): stop create-new-feature.ps1 crashing on a description with no ASCII words#4138jawwad-ali wants to merge 1 commit into
create-new-feature.ps1 crashing on a description with no ASCII words#4138jawwad-ali wants to merge 1 commit into
Conversation
…ription
Get-BranchName's fallback assumed the pipeline yields at least one element:
$fallbackWords = ($result -split '-') | Where-Object { $_ } | ...
return [string]::Join('-', $fallbackWords)
ConvertTo-CleanBranchName blanks every non-[a-z0-9] character, so a
description written in any non-Latin script leaves nothing for the pipeline
to emit. It yields $null, [string]::Join throws ArgumentNullException, and
$ErrorActionPreference = 'Stop' makes that terminating — the script dies
with a .NET stack trace, empty stdout, exit 1.
Measured with all three twins installed in one project:
desc='добавить авторизацию'
bash rc=0 BRANCH_NAME='001-'
py rc=0 BRANCH_NAME='001-'
ps rc=1 Exception calling "Join" ...
Identical for 添加用户认证 and '!!! ??? ***'. This hits every PowerShell
user who phrases a feature in their own language.
Wrap the pipeline in @() so it stays an array; Join on an empty array
returns "", matching the twins. Verified the normal case is unchanged
('a-to-the-of' -> 'a-to-the', 'add user authentication' ->
'001-user-authentication'), and the file stays ASCII-only (0 non-ASCII
bytes) for tests/test_ps1_encoding.py.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Get-BranchName's fallback branch assumes the pipeline yields at least one element:ConvertTo-CleanBranchNamedoes$Description.ToLower() -replace '[^a-z0-9\s]', ' ', which blanks every non-ASCII character. So a description written in any non-Latin script leaves nothing for the pipeline to emit:$fallbackWordsis$null[string]::Join('-', $null)throwsArgumentNullException$ErrorActionPreference = 'Stop'makes it terminatingThe script dies with a .NET stack trace, empty stdout, exit 1.
Reproduction on current
main(bf88c9f)All three twins installed into one project, same args, same cwd:
Identical for
添加用户认证and'!!! ??? ***'. The bash and Python twins both return an empty suffix and succeed.This hits every PowerShell user who phrases a feature in their own language — Cyrillic, Han, Kana, Arabic, Greek, Hebrew — plus punctuation-only and accent-only descriptions.
Fix
Wrap the pipeline in
@()so it stays an array. Verified at the primitive level:After the fix, the same three descriptions:
No breaking change. The only inputs whose behaviour changes are ones that today raise and exit 1. The file stays ASCII-only (verified 0 non-ASCII bytes) so
tests/test_ps1_encoding.py::test_ps1_file_is_ascii_onlystill passes.Verification
001-for the same input.mainbaseline captured onbf88c9f9.uvx ruff@0.15.0 check src tests→ cleanWritten with assistance from Claude Code. Bug found, reproduced, and verified by me on current
mainwith realpowershell.exe.