SeleniumHQ/selenium · error · ValueError

NuGet index returned no versions for DocFX

Error message

NuGet index returned no versions for DocFX

What it means

Thrown in main() when the NuGet flat-container index for 'docfx' returns successfully but its 'versions' key is missing or an empty list. This is distinct from a parse failure: the index itself is structurally valid JSON but advertises zero downloadable versions, implying the package id is wrong, the package was delisted, or the endpoint returned a degenerate response.

Source

Thrown at scripts/update_docfx.py:121

        "--version",
        help="Use this DocFX version instead of the latest stable.",
    )
    parser.add_argument(
        "--allow-prerelease",
        action="store_true",
        help="Allow prerelease versions when selecting latest.",
    )
    parser.add_argument(
        "--output",
        default="dotnet/private/docfx_repo.bzl",
        help="Output file path (default: dotnet/private/docfx_repo.bzl)",
    )
    args = parser.parse_args()

    index = fetch_json(NUGET_INDEX_URL)
    versions = index.get("versions", [])
    if not versions:
        raise ValueError("NuGet index returned no versions for DocFX")

    version = choose_version(versions, args.allow_prerelease, args.version)
    nupkg_url = NUGET_NUPKG_URL.format(version=version)
    sha256 = sha256_of_url(nupkg_url)

    output_path = Path(args.output)
    if not output_path.is_absolute():
        workspace_dir = os.environ.get("BUILD_WORKSPACE_DIRECTORY")
        if workspace_dir:
            output_path = Path(workspace_dir) / output_path
    output_path.write_text(render_docfx_repo(version, sha256))

    print(f"Updated {output_path} to DocFX {version}")


if __name__ == "__main__":
    main()

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Confirm the package exists: open https://api.nuget.org/v3-flatcontainer/docfx/index.json in a browser and verify a populated 'versions' array.
  2. Check for transient failures by re-running the script after a short wait.
  3. Verify NUGET_INDEX_URL (line 17) matches the current NuGet v3-flatcontainer endpoint format.
  4. If the package id changed, update the URL constant and the NUPKG template.
Defensive patterns

Strategy: try-catch

Validate before calling

index = fetch_json(NUGET_INDEX_URL)
if not isinstance(index, dict) or not index.get("versions"):
    raise SystemExit(f"NuGet index empty/invalid; response was: {str(index)[:200]}")

Try / catch

try:
    index = fetch_json(NUGET_INDEX_URL)
    versions = index.get("versions", [])
    if not versions:
        raise ValueError("NuGet index returned no versions for DocFX")
except (urllib3.exceptions.HTTPError, json.JSONDecodeError) as e:
    print(f"Failed to fetch NuGet index: {e}", file=sys.stderr)
    sys.exit(1)

Prevention

When it happens

Trigger: fetch_json(NUGET_INDEX_URL) succeeds and json.loads produces a dict, but index.get('versions', []) yields []. This happens before choose_version is ever called.

Common situations: The package id 'docfx' was renamed/abandoned on NuGet; a transient CDN issue returned `{}`; an incorrect NUGET_INDEX_URL constant points at a non-existent package; network filtering returned a 200 with an empty body that parsed to a minimal object.

Related errors


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