{"record":{"id":"ca8519439759dbda","repo":"SeleniumHQ/selenium","slug":"nuget-index-returned-no-versions-for-docfx","errorCode":null,"errorMessage":"NuGet index returned no versions for DocFX","messagePattern":"NuGet index returned no versions for DocFX","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/update_docfx.py","lineNumber":121,"sourceCode":"        \"--version\",\n        help=\"Use this DocFX version instead of the latest stable.\",\n    )\n    parser.add_argument(\n        \"--allow-prerelease\",\n        action=\"store_true\",\n        help=\"Allow prerelease versions when selecting latest.\",\n    )\n    parser.add_argument(\n        \"--output\",\n        default=\"dotnet/private/docfx_repo.bzl\",\n        help=\"Output file path (default: dotnet/private/docfx_repo.bzl)\",\n    )\n    args = parser.parse_args()\n\n    index = fetch_json(NUGET_INDEX_URL)\n    versions = index.get(\"versions\", [])\n    if not versions:\n        raise ValueError(\"NuGet index returned no versions for DocFX\")\n\n    version = choose_version(versions, args.allow_prerelease, args.version)\n    nupkg_url = NUGET_NUPKG_URL.format(version=version)\n    sha256 = sha256_of_url(nupkg_url)\n\n    output_path = Path(args.output)\n    if not output_path.is_absolute():\n        workspace_dir = os.environ.get(\"BUILD_WORKSPACE_DIRECTORY\")\n        if workspace_dir:\n            output_path = Path(workspace_dir) / output_path\n    output_path.write_text(render_docfx_repo(version, sha256))\n\n    print(f\"Updated {output_path} to DocFX {version}\")\n\n\nif __name__ == \"__main__\":\n    main()\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/scripts/update_docfx.py#L103-L139","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the package exists: open https://api.nuget.org/v3-flatcontainer/docfx/index.json in a browser and verify a populated 'versions' array.","Check for transient failures by re-running the script after a short wait.","Verify NUGET_INDEX_URL (line 17) matches the current NuGet v3-flatcontainer endpoint format.","If the package id changed, update the URL constant and the NUPKG template."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"index = fetch_json(NUGET_INDEX_URL)\nif not isinstance(index, dict) or not index.get(\"versions\"):\n    raise SystemExit(f\"NuGet index empty/invalid; response was: {str(index)[:200]}\")","typeGuard":null,"tryCatchPattern":"try:\n    index = fetch_json(NUGET_INDEX_URL)\n    versions = index.get(\"versions\", [])\n    if not versions:\n        raise ValueError(\"NuGet index returned no versions for DocFX\")\nexcept (urllib3.exceptions.HTTPError, json.JSONDecodeError) as e:\n    print(f\"Failed to fetch NuGet index: {e}\", file=sys.stderr)\n    sys.exit(1)","preventionTips":["Add retry logic around fetch_json for transient network failures.","Cache the last-known-good index locally as a fallback.","Validate the response is a dict with a non-empty list before proceeding."],"tags":["python","build-script","nuget","network","validation"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}