Validate channel format in dotnet-install.sh#693
Open
luissena wants to merge 1 commit intodotnet:mainfrom
Open
Validate channel format in dotnet-install.sh#693luissena wants to merge 1 commit intodotnet:mainfrom
luissena wants to merge 1 commit intodotnet:mainfrom
Conversation
When an unsupported channel format is provided (e.g., `-c 10`), the script now exits early with a clear error message listing the supported formats (STS, LTS, A.B, A.B.Cxx) instead of proceeding to construct invalid URLs that fail with confusing 404 errors. Fixes dotnet#686
mmitche
reviewed
Mar 26, 2026
| if [[ "$channel" =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
| echo "$channel" | ||
| return 0 | ||
| elif [[ "$channel" =~ ^[0-9]+\.[0-9]+\.[0-9]+[a-z]{2}$ ]]; then |
Member
There was a problem hiding this comment.
I think this needs to be a bit more flexible and consider daily and preview packages. They'll have channel names like:
11.0.1xx-preview2:
.\.dotnet\dotnet-install.ps1 -channel 11.0.1xx-preview2 -verbose -Quality daily
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.
Summary
Fixes #686
When an unsupported channel format is provided (e.g.,
-c 10), the script now exits early with a clear error message instead of proceeding to construct invalid URLs that fail with confusing 404 errors.Changes
src/dotnet-install.sh: Added channel format validation inget_normalized_channel(). The wildcard case now validates that the channel matches either a 2-part version (A.B, e.g.,10.0) or a 3-part SDK band version (A.B.Cxx, e.g.,5.0.1xx). Invalid formats produce a clear error message listing supported formats, following the same pattern used byget_normalized_quality().tests/.../GivenThatIWantToGetTheSdkLinksFromAScript.cs: Added[InlineData("10")]test case and updated the expected error message assertion to match the new validation message.Before
After