SeleniumHQ/selenium · error · ValueError

Requested DocFX version {explicit_version!r} not found in Nu

Error message

Requested DocFX version {explicit_version!r} not found in NuGet index

What it means

Thrown by choose_version() in scripts/update_docfx.py when the --version flag specifies a DocFX release that does not exist in the NuGet flat-container index (NUGET_INDEX_URL). The script fetches the full version list from NuGet and, before accepting the user-supplied version, verifies it is present in that list. A mismatch means the string (including any pre-release suffix) was never published to NuGet under the 'docfx' package id.

Source

Thrown at scripts/update_docfx.py:31

import urllib3
from packaging.version import InvalidVersion, Version

NUGET_INDEX_URL = "https://api.nuget.org/v3-flatcontainer/docfx/index.json"
NUGET_NUPKG_URL = "https://api.nuget.org/v3-flatcontainer/docfx/{version}/docfx.{version}.nupkg"

http = urllib3.PoolManager()


def fetch_json(url):
    r = http.request("GET", url)
    return json.loads(r.data)


def choose_version(versions, allow_prerelease, explicit_version=None):
    if explicit_version:
        if explicit_version not in versions:
            raise ValueError(f"Requested DocFX version {explicit_version!r} not found in NuGet index")
        return explicit_version

    parsed = []
    for v in versions:
        try:
            pv = Version(v)
        except InvalidVersion:
            continue
        if not allow_prerelease and pv.is_prerelease:
            continue
        parsed.append((pv, v))

    if not parsed:
        if allow_prerelease:
            raise ValueError("No parseable DocFX versions found in NuGet index")
        else:
            raise ValueError("No stable DocFX versions found. Use --allow-prerelease to include prereleases.")

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Verify the version string against the live index: open https://api.nuget.org/v3-flatcontainer/docfx/index.json and copy an exact value from its 'versions' array.
  2. Remove the --version flag to let the script auto-select the latest stable release.
  3. If you need a pre-release, confirm the exact suffix (e.g. -preview.123) matches the index character-for-character.
  4. Re-run with the corrected version string.

Example fix

# before
python scripts/update_docfx.py --version 2.99.0

# after
python scripts/update_docfx.py --version 2.78.2
Defensive patterns

Strategy: validation

Validate before calling

# Validate --version against the live index before calling choose_version
import urllib3, json
from packaging.version import Version

http = urllib3.PoolManager()
index = json.loads(http.request("GET", "https://api.nuget.org/v3-flatcontainer/docfx/index.json").data)
available = set(index.get("versions", []))
requested = "2.78.2"
if requested not in available:
    raise SystemExit(f"{requested!r} not published. Pick from: {sorted(available)[-5:]}")

Try / catch

try:
    version = choose_version(versions, args.allow_prerelease, args.version)
except ValueError as e:
    print(f"Version selection failed: {e}", file=sys.stderr)
    print("Check https://api.nuget.org/v3-flatcontainer/docfx/index.json", file=sys.stderr)
    sys.exit(1)

Prevention

When it happens

Trigger: Running `python scripts/update_docfx.py --version X.Y.Z` where X.Y.Z is not in the index. Fetching the index succeeds (a JSON object with a non-empty 'versions' array), but the explicit_version string does not exact-match any entry. Common triggers: a typo, a wrong pre-release suffix, or requesting a version that was yanked/never published.

Common situations: A maintainer pins DocFX to a specific release to reproduce a doc bug, mistyping the number; CI reruns an old job after DocFX yanked a release; someone copies a version from an outdated blog post that does not exist on NuGet.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/8800c8dd95727797. Report an issue: GitHub.