Skip to content

Initialize resource when GetInstalledVersions is called first#7245

Merged
nkolev92 merged 2 commits intodevfrom
dev-nkolev92-InitializeResource
Apr 14, 2026
Merged

Initialize resource when GetInstalledVersions is called first#7245
nkolev92 merged 2 commits intodevfrom
dev-nkolev92-InitializeResource

Conversation

@nkolev92
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 commented Mar 31, 2026

Bug

Fixes: NuGet/Home#14837

Description

This could lead to some false negatives in some cases.
Note that in all non-lock file scenarios other methods would be called first in the restore codepaths, so it's fortuituously initialized.
In lock file scenarios with 1 package, that's not the case and that's what my test is/was.
NuGet/Home#14107 (comment)

This is not very likely to be a thing in practice, as it would effectively require a single package scenarios so that other calls to the source don't end up initializing things.

Note that I switched the throttle semaphore acquisition and the EnsureResource calls in a few places. Tests were failing without it.
If EnsureResource failed, we'd release the semaphore despite never acquiring it, leading to SemaphoreFullException.

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.

@nkolev92 nkolev92 marked this pull request as ready for review March 31, 2026 22:29
@nkolev92 nkolev92 requested a review from a team as a code owner March 31, 2026 22:29
@nkolev92 nkolev92 requested review from jebriede and martinrrm March 31, 2026 22:29
jeffkl
jeffkl previously approved these changes Mar 31, 2026
martinrrm
martinrrm previously approved these changes Apr 1, 2026
@nkolev92 nkolev92 enabled auto-merge (squash) April 1, 2026 20:38
@Nigusu-Allehu Nigusu-Allehu marked this pull request as draft April 7, 2026 23:09
auto-merge was automatically disabled April 7, 2026 23:09

Pull request was converted to draft

@nkolev92 nkolev92 dismissed stale reviews from martinrrm and jeffkl via 57b10e4 April 10, 2026 20:42
@nkolev92 nkolev92 marked this pull request as ready for review April 13, 2026 16:11
@nkolev92 nkolev92 merged commit 398128e into dev Apr 14, 2026
17 of 18 checks passed
@nkolev92 nkolev92 deleted the dev-nkolev92-InitializeResource branch April 14, 2026 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SourceRepositoryDependencyProvider.GetInstalledVersions returns null when packages may be available.

3 participants