- 
                Notifications
    You must be signed in to change notification settings 
- Fork 715
Simplify Aspire CLI project name validation to only reject path separators #10714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify Aspire CLI project name validation to only reject path separators #10714
Conversation
…comprehensive tests Co-authored-by: mitchdenny <[email protected]>
…alidation regex Co-authored-by: mitchdenny <[email protected]>
Co-authored-by: davidfowl <[email protected]>
| @copilot revert the last commit and put the validation logic back in, but change the validation logic so that the only invalid characters are path separators (/ and ). | 
Co-authored-by: mitchdenny <[email protected]>
| 
 I've reverted the last commit and restored the validation logic with the simplified approach you requested. The ProjectNameValidator now only rejects path separators (/ and ) while allowing all other characters including Unicode, special symbols, and spaces. All tests have been updated accordingly. Commit 020c076. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR simplifies the Aspire CLI project name validation from a restrictive ASCII-only approach to a permissive model that only rejects path separators. The change enables users to create projects with Unicode names (Chinese, Arabic, Cyrillic, etc.) and special characters while maintaining essential path safety.
Key Changes:
- Replaced complex Unicode-aware regex with simple path separator rejection
- Updated validation to allow all characters except forward slash (/) and backslash ()
- Expanded test coverage to include diverse Unicode scripts and edge cases
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description | 
|---|---|
| src/Aspire.Cli/Commands/NewCommand.cs | Simplified ProjectNameValidatorregex from ASCII-only to path-separator exclusion only | 
| tests/Aspire.Cli.Tests/Commands/ProjectNameValidatorTests.cs | Added comprehensive test suite covering Unicode scripts, special characters, and validation edge cases | 
| [InlineData("Project/1", false)] // Forward slash (path separator) | ||
| [InlineData("Project\\1", false)] // Backslash (path separator) | ||
| [InlineData("", false)] // Empty string | ||
| [InlineData(" ", false)] // Space only | 
    
      
    
      Copilot
AI
    
    
    
      Aug 5, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case expects spaces-only strings to be invalid, but the current regex ^[^/\\]{1,254}$ will actually match single spaces since space is not a path separator. The test expectation contradicts the actual regex behavior.
| [InlineData("Project\\1", false)] // Backslash (path separator) | ||
| [InlineData("", false)] // Empty string | ||
| [InlineData(" ", false)] // Space only | ||
| [InlineData(" ", false)] // Multiple spaces only | 
    
      
    
      Copilot
AI
    
    
    
      Aug 5, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case expects multiple spaces to be invalid, but the regex ^[^/\\]{1,254}$ will match multiple spaces since spaces are not path separators. The test expectation contradicts the actual regex behavior.
| [InlineData(" ", false)] // Multiple spaces only | |
| [InlineData(" ", true)] // Multiple spaces only | 
| [InlineData("", false)] // Empty string | ||
| [InlineData(" ", false)] // Space only | ||
| [InlineData(" ", false)] // Multiple spaces only | ||
| [InlineData("\t", false)] // Tab only | 
    
      
    
      Copilot
AI
    
    
    
      Aug 5, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case expects tab-only strings to be invalid, but the regex ^[^/\\]{1,254}$ will match tabs since tab is not a path separator. The test expectation contradicts the actual regex behavior.
| [InlineData("\t", false)] // Tab only | |
| [InlineData("\t", true)] // Tab only | 
| [InlineData(" ", false)] // Space only | ||
| [InlineData(" ", false)] // Multiple spaces only | ||
| [InlineData("\t", false)] // Tab only | ||
| [InlineData("\n", false)] // Newline only | 
    
      
    
      Copilot
AI
    
    
    
      Aug 5, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case expects newline-only strings to be invalid, but the regex ^[^/\\]{1,254}$ will match newlines since newline is not a path separator. The test expectation contradicts the actual regex behavior.
| [InlineData("\n", false)] // Newline only | |
| [InlineData("\n", true)] // Newline only | 
| /backport to release/9.4 | 
| Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16738186460 | 
Fixes #10629
The Aspire CLI was implementing overly restrictive project name validation that prevented users from creating projects with Unicode names and many special characters. Following architectural feedback, this PR simplifies the validation to only reject path separators while allowing maximum compatibility.
Changes Made
New Validation Logic
The simplified validation:
Benefits
Examples
Now supported:
项目1(Chinese)Проект1(Cyrillic)مشروع1(Arabic)Project*Name(with asterisk)My:Project(with colon)Project Name(with spaces)Still rejected:
Project/Name(forward slash)Project\Name(backslash)This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.