Skip to content

Validate channel format in dotnet-install.sh#693

Open
luissena wants to merge 1 commit intodotnet:mainfrom
luissena:validate-channel-format
Open

Validate channel format in dotnet-install.sh#693
luissena wants to merge 1 commit intodotnet:mainfrom
luissena:validate-channel-format

Conversation

@luissena
Copy link
Copy Markdown

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 in get_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 by get_normalized_quality().

  • tests/.../GivenThatIWantToGetTheSdkLinksFromAScript.cs: Added [InlineData("10")] test case and updated the expected error message assertion to match the new validation message.

Before

$ bash dotnet-install.sh -c 10 --verbose
# ... attempts to download from invalid URLs, gets 404
# "Failed to resolve the exact version number."

After

$ bash dotnet-install.sh -c 10
# "'10' is not a supported value for --channel option. Supported values are:
#  STS, LTS, a 2-part version in A.B format (e.g., 10.0), or a 3-part SDK
#  band version in A.B.Cxx format (e.g., 5.0.1xx)."

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
if [[ "$channel" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "$channel"
return 0
elif [[ "$channel" =~ ^[0-9]+\.[0-9]+\.[0-9]+[a-z]{2}$ ]]; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Improve output for unsupported one-part channel in dotnet-install.sh

2 participants