Fix bare NullReferenceException for missing NuGet V3 package version (FD-440)#1989
Open
droyad wants to merge 1 commit into
Open
Fix bare NullReferenceException for missing NuGet V3 package version (FD-440)#1989droyad wants to merge 1 commit into
droyad wants to merge 1 commit into
Conversation
…(FD-440) When Calamari downloads a package from a NuGet V3 feed and the requested version does not exist on the feed, the deployment failed with an opaque NullReferenceException instead of a clear "version not found" message. The NRE originates inside the (forked) NuGet.Commands SourceRepositoryDependencyProvider.GetPackageDownloaderAsync: the inner FindPackageByIdResource returns a null downloader for an absent version, which the provider then dereferences unconditionally. Calamari calls the API correctly and cannot stop the library dereferencing its own null, so NuGetV3LibDownloader now pre-checks that the version exists and throws an actionable error that folds into the existing retry messaging. This affects the "download on target" path (Calamari) and is independent of feed authentication; reproduced anonymously against api.nuget.org. Co-Authored-By: Claude Opus 4.8 (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
When Calamari downloads a package from a NuGet V3 feed and the requested version does not exist on the feed, the deployment fails with an opaque
NullReferenceExceptioninstead of a clear "package/version not found" message:The NRE is thrown inside the (forked) NuGet client library, not Calamari.
SourceRepositoryDependencyProvider.GetPackageDownloaderAsyncretrieves a downloader from the innerFindPackageByIdResourceand then unconditionally callsSetThrottle/SetExceptionHandleron it — but for a version that isn't on the feed, that downloader isnull. Calamari calls the API correctly; it just can't stop the library dereferencing its own null.A customer who selects a version that was never published (CI didn't push it, wrong version selected, etc.) gets a meaningless
NullReferenceExceptionwith no hint that the real issue is a missing package version.Scope
NuGetV3LibDownloader). The server-side acquisition path (ExternalHttpNuGetPackageFeed) already surfaces a clean "NotFound" message — different code path.api.nuget.org. Bad-credentials (401) is a separate, already-handled case.GetPackageDownloaderAsynccall replaced the olderCopyToAsyncpath in commitea707ed8c("#6965 Updated to latest version of NuGet.Commands", 2021-08-09) and has had no null guard since.Reproduction
Reproduced end-to-end in the product: https://main.testoctopus.app/app#/Spaces-203/projects/download-problem/deployments/releases/0.0.3/deployments/Deployments-98822
The added integration test (
GivesActionableErrorWhenV3FeedIsMissingTheRequestedVersion) reproduces the exact NRE againstapi.nuget.orgwhen the guard is absent, and confirms the actionable message when present.Fixes FD-440.
🤖 Generated with Claude Code