Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package version to query string for v2 CDN endpoint #10082

Open
clairernovotny opened this issue Jul 26, 2024 · 0 comments
Open

Add package version to query string for v2 CDN endpoint #10082

clairernovotny opened this issue Jul 26, 2024 · 0 comments

Comments

@clairernovotny
Copy link
Contributor

The v2 endpoint for package downloads redirects incoming requests to the CDN storage:

https://www.nuget.org/api/v2/package/Newtonsoft.Json/13.0.3 -> https://<cdn host>/packages/newtonsoft.json.13.0.3.nupkg

When parsing versions in the logs for statistics, determining the package version can be ambiguous if the package id ends in a number. For example, package id Frob.2 with version 1.0 would turn into https://<cdn host>/packages/frob.2.1.0.nupkg, making it ambiguous what the package id and version really are.

This will turn the download URL into https://<cdn host>/packages/frob.2.1.0.nupkg?packageVersion=1.0, removing the ambiguity.

Note that this isn't an issue for the v3 endpoints as the v3 download URLs have the version in the path already.

@clairernovotny clairernovotny self-assigned this Jul 26, 2024
clairernovotny added a commit that referenced this issue Jul 26, 2024
Add the packageVersion to the query string of cdn redirect url's

Added a new constant `PackageVersionParameterName` to `CoreConstants.cs`.
Reorganized and added necessary `using` directives in multiple files.
Modified `CloudBlobFileStorageService` to include and handle the new `versionParameter` in its constructor and methods.
Refactored `GetRedirectUri` to include the `versionParameter` in the query string.
Added a helper method `ParseQueryString` in `CloudBlobFileStorageService`.
Updated `IFileStorageService` interface to include the `versionParameter`.
Updated `FileSystemFileStorageService` and `SymbolPackageFileService` to handle the `versionParameter`.
Updated `PackageFileService` to pass the `versionParameter`.
Updated and added tests in corresponding test files to verify the handling of the `versionParameter`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants