Skip to content

Check the nuspec stream in OpenNuspecFromNupkg - #7813

Merged
zivkan merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-nuspec-null-check
Oct 27, 2026
Merged

zivkan merged 1 commit into
NuGet:devfrom
AsadIqbal-Dev:dev-asadiqbal-nuspec-null-check

Conversation

@AsadIqbal-Dev

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#9724

Description

PackageUtilities.OpenNuspecFromNupkg gets the nuspec stream and then checks nupkgStream == null instead of nuspecStream == null, as the issue points out. The check now tests the stream it was meant to.

PackageArchiveReader.GetNuspec() throws a PackagingException when the package has no nuspec, so the null branch isn't reachable with the current reader. The fix just makes the guard correct. There were no tests for this method, so I added two:

  • a package returns its nuspec
  • a package without a nuspec throws PackagingException, the path a missing nuspec really takes today

NuGet.Protocol.Tests (PackageUtilitiesTests and FindPackagesByIdNupkgDownloaderTests) on net10.0: 15 passed.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@zivkan
zivkan merged commit 3fab345 into NuGet:dev Oct 27, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Browsing through the source code - possible bug in PackageUtilities?

2 participants