| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
… 1657) Co-authored-by: et1975 <623703+et1975@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Sorry, something went wrong.
There was a problem hiding this comment.
Fixes incorrect V3 .nupkg selection during Install/Save by replacing substring-based URL matching with parsed NuGetVersion comparisons, preventing version-prefix collisions (e.g., 1.2.3 vs 1.2.30) that can download the wrong payload into the requested version folder.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/code/V3ServerAPICalls.cs | Introduces version-parsing URL matcher and uses it in sync/async install paths. |
| src/code/PSResourceInfo.cs | Adds TestHooks.SelectV3PackageContentUrl to expose selection logic for tests. |
| test/InstallPSResourceTests/InstallPSResourceV3ServerVersionSelection.Tests.ps1 | Adds tests covering exact-match selection across several URL/version shapes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
…election Co-authored-by: et1975 <623703+et1975@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Summary
Install-PSResource/Save-PSResource against a V3 feed can download the payload of a different version than requested while writing it under the requested version's folder. The V3 download path picked the packageContent URL by substring match, so a requested version that is a text prefix of another version matched the wrong entry.
V3ServerAPICalls.InstallHelper and InstallHelperAsync did:
// versionedResponses are in descending version order, first match wins if (response.Contains(version.ToNormalizedString())) { pkgContentUrl = response; break; }Requesting 1.2.3 matches .../test_module/1.2.30/test_module.1.2.30.nupkg first. This also explains why exact-range syntax ([1.2.3]) doesn't help: by this point the spec is already a parsed NuGetVersion, and only the final URL selection is text-based. FindVersionHelper already compares parsed versions, which is why Find reports the right version while the downloaded content is wrong.
Closes #1657
Changes
src/code/V3ServerAPICalls.cs — new GetPackageContentUrlForVersion helper that extracts the version from a packageContent entry and compares it as a NuGetVersion. Recognized shapes: version path segment (.../{name}/{version}/...), .{version}.nupkg file name suffix, and version-bearing query parameters (e.g. MyGet-style ?packageVersion=). Both the sync and async install paths now use it.
src/code/PSResourceInfo.cs — TestHooks.SelectV3PackageContentUrl entry point, following the existing TestHooks pattern, so URL selection is testable without a live feed.
test/InstallPSResourceTests/InstallPSResourceV3ServerVersionSelection.Tests.ps1 — covers 1.2.3 vs 1.2.30, the reported 2024.5.20.1 vs 2024.5.20.12, prereleases (2.5.0-beta1 vs 2.5.0-beta10), query-parameter URLs, and the not-found case. The prefix cases fail against the previous substring logic.
Behavioral note
Entries whose version can't be recovered from the URL are no longer matched at all, rather than being matched on any incidental substring occurrence. Non-matching now surfaces the existing "could not be found in repository" error instead of silently downloading a neighboring version.
PR Checklist