PowerShell / PowerShell/PSResourceGet

NuGet v3 Optimization: Don't request registrationpages outside version request range

Open
#1,449 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-PSRepository feature_request
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Summary of the new feature / enhancement

When fetching Nuget v3 info, only pages that contain the requested version should be fetched. All version info is present on the Registration Index by virtue of the upper and lower markers. For example:
https://pwsh.gallery/invokebuild/index.json

{
  "@id": "https://pwsh.gallery/invokebuild/index.json",
  "count": 3,
  "items": [
    {
      "@id": "https://pwsh.gallery/invokebuild/index.json#page/latest",
      "lower": "5.10.4",
      "upper": "5.10.4",
      "count": 1,
      "items": [
        {
          "@id": "https://pwsh.gallery/invokebuild/5.10.4.json",
          "catalogEntry": {
            "@id": "https://pwsh.gallery/invokebuild/5.10.4.json#catalogEntry",
            "id": "InvokeBuild",
            "version": "5.10.4",
            "tags": [],
            "dependencyGroups": []
          },
          "packageContent": "https://www.powershellgallery.com/api/v2/package/InvokeBuild/5.10.4"
        }
      ]
    },
    {
      "@id": "https://pwsh.gallery/invokebuild/page/other.json",
      "lower": "3.2.0",
      "upper": "5.10.3",
      "count": 99
    },
    {
      "@id": "https://pwsh.gallery/invokebuild/page/older.json",
      "lower": "0.0.0",
      "upper": "3.2.0",
      "count": 0
    }
  ]
}

In this case, the latest version is inlined, so no additional page queries should be made. If version 3.2.1 is requested, then only other.json should be requested and not older.json. Currently PSResourceGet inefficiently fetches all pages, which in this example is simple, but in other v3 repositories could be hundreds of calls.

As an example, with pwsh.gallery:

DEBUG: Request url is 'https://pwsh.gallery/index.json'
DEBUG: In V3ServerAPICalls::FindRegistrationsBaseUrl()
DEBUG: In V3ServerAPICalls::GetVersionedResponsesFromRegistrationsResource()
DEBUG: In V3ServerAPICalls::HttpRequestCall()
DEBUG: Request url is 'https://pwsh.gallery/invokebuild/index.json'
DEBUG: In V3ServerAPICalls::GetMetadataElementsFromResponse()
DEBUG: In V3ServerAPICalls::GetMetadataElementFromItemsElement()
DEBUG: In V3ServerAPICalls::GetMetadataElementFromIdLinkElement()
DEBUG: In V3ServerAPICalls::HttpRequestCall()
DEBUG: Request url is 'https://pwsh.gallery/invokebuild/page/other.json'
DEBUG: In V3ServerAPICalls::GetMetadataElementFromIdLinkElement()
DEBUG: In V3ServerAPICalls::HttpRequestCall()
DEBUG: Request url is 'https://pwsh.gallery/invokebuild/page/older.json'
Proposed technical implementation details (optional)

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the V3ServerAPICalls methods named in the report, especially GetVersionedResponsesFromRegistrationsResource and GetMetadataElementsFromResponse, and trace how registration index page bounds are processed. Verify requests are limited to pages whose lower and upper markers can contain the requested version, while inlined matching items require no page request; use the debug request sequence in the issue to confirm the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.