Fix #310: skip non-HTTP NuGet sources instead of crashing#317
Merged
richlander merged 3 commits intomainfrom May 4, 2026
Merged
Fix #310: skip non-HTTP NuGet sources instead of crashing#317richlander merged 3 commits intomainfrom
richlander merged 3 commits intomainfrom
Conversation
A local folder source from NuGet.Config (e.g. `D:\some\local\packages`) listed before a working HTTP feed caused `System.NotSupportedException: net_http_unsupported_requesturi_scheme, file` when resolving package versions or downloading nupkgs: PackageExtractor.GetPackageBaseAddressAsync built a service-index URL from source.Url and handed it to HttpClient, whose HttpRequestMessage ctor throws on file/relative URLs. Fix: in GetPackageBaseAddressAsync, return null for any source whose URL is not an absolute http/https URI (and log it). The existing source loops already treat null as 'try next source', so nuget.org / private HTTP feeds listed after a folder source now resolve correctly. Defense in depth: catch NotSupportedException in HttpRetryHelper.ExecuteWithRetryAsync so any future code path that accidentally passes an unsupported URL degrades to a skipped source rather than crashing the command. Adds regression tests covering: - Windows folder paths, POSIX paths, file:// URLs, and unparseable URLs do not crash GetLatestVersionAsync, GetVersionsAsync, or GetPackageDownloadUrlAsync. - A local folder source listed before nuget.org no longer prevents resolution from succeeding (the exact scenario from the issue). - Skipped non-HTTP sources are surfaced via the log callback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… SDK regression Direct stdout-to-file redirection (`cmd > file.md`) truncates the AOT binary's output to ~256 bytes on the .NET 11 preview 3 SDK (11.0.100-preview.3.26207.106) currently used by GitHub-hosted runners. Piping through `cat` keeps the output complete. Reproduced locally on macOS arm64 with the released 0.7.6 binary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 4, 2026
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.
Fixes #310.
A local folder source from
NuGet.Config(e.g.D:\some\local\packages) listed before a working HTTP feed causedSystem.NotSupportedException: net_http_unsupported_requesturi_scheme, filewhen resolving package versions or downloading nupkgs.PackageExtractor.GetPackageBaseAddressAsyncbuilt a service-index URL fromsource.Urland handed it toHttpClient, whoseHttpRequestMessagector throws on file/relative URLs.Fix
GetPackageBaseAddressAsync, return null for any source whose URL is not an absolute http/https URI (and log it). The download / list-versions / latest-version paths all flow through this method after the nuget.org flat-container shortcut, so one guard fixes all three. Existing source loops already treat null as "try next source", so HTTP feeds listed after a folder source now resolve correctly.NotSupportedExceptioninHttpRetryHelper.ExecuteWithRetryAsyncso any future code path that accidentally passes an unsupported URL degrades to a skipped source rather than crashing.Tests
New
LocalFolderSourceTestscovers:file://URLs, and unparseable URLs do not crashGetLatestVersionAsync,GetVersionsAsync, orGetPackageDownloadUrlAsync.All existing tests still pass:
DotnetInspector.Services.Tests155/155,dotnet-inspect.Tests614/614 (31 unrelated skips for missingilspycmd).Out of scope
Adding real support for enumerating versions / downloading from local folder sources (issue's suggested option 3). The primary requirement was "don't crash".