{"record":{"id":"3179ba5dd83be635","repo":"SeleniumHQ/selenium","slug":"no-parseable-docfx-versions-found-in-nuget-index","errorCode":null,"errorMessage":"No parseable DocFX versions found in NuGet index","messagePattern":"No parseable DocFX versions found in NuGet index","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/update_docfx.py","lineNumber":46,"sourceCode":"def choose_version(versions, allow_prerelease, explicit_version=None):\n    if explicit_version:\n        if explicit_version not in versions:\n            raise ValueError(f\"Requested DocFX version {explicit_version!r} not found in NuGet index\")\n        return explicit_version\n\n    parsed = []\n    for v in versions:\n        try:\n            pv = Version(v)\n        except InvalidVersion:\n            continue\n        if not allow_prerelease and pv.is_prerelease:\n            continue\n        parsed.append((pv, v))\n\n    if not parsed:\n        if allow_prerelease:\n            raise ValueError(\"No parseable DocFX versions found in NuGet index\")\n        else:\n            raise ValueError(\"No stable DocFX versions found. Use --allow-prerelease to include prereleases.\")\n\n    return max(parsed, key=lambda item: item[0])[1]\n\n\ndef sha256_of_url(url):\n    digest = hashlib.sha256()\n    r = http.request(\"GET\", url, preload_content=False)\n    for chunk in r.stream(1024 * 1024):\n        digest.update(chunk)\n    r.release_conn()\n    return digest.hexdigest()\n\n\ndef render_docfx_repo(version, sha256):\n    return f'''\\\n\"\"\"Repository rule to download the docfx NuGet package.\"\"\"","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/scripts/update_docfx.py#L28-L64","documentation":"Raised in choose_version() when --allow-prerelease is enabled yet every version in the NuGet index failed to parse via packaging.Version (InvalidVersion). It indicates the entire published list is structurally unparseable by PEP 440, which should not happen for a real package but guards against corrupted or schema-changed indexes.","triggerScenarios":"Calling `python scripts/update_docfx.py --allow-prerelease` and the loop at line 34-42 appends nothing because every version string raises InvalidVersion. The index was fetched (non-empty) but no entry conformed to PEP 440.","commonSituations":"NuGet changes its index schema so 'versions' contains objects instead of plain strings; a mirror/CDN returns an HTML error page that json.loads turned into unexpected structures; an experimental DocFX fork publishes non-PEP440 tags.","solutions":["Manually inspect the fetched index: `curl -s https://api.nuget.org/v3-flatcontainer/docfx/index.json | python -m json.tool` and check the shape of the 'versions' array.","If the index structure changed, update fetch_json/choose_version to match the new schema.","Retry without --allow-prerelease to see if error 302 also fires (confirming a parse problem rather than a pre-release-only situation).","Report the schema change upstream if the index is genuinely malformed."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Sanity-check that the index contains at least one PEP 440 version\nfrom packaging.version import Version, InvalidVersion\nparseable = [v for v in versions if _is_valid(Version, v)]\nif args.allow_prerelease and not parseable:\n    raise SystemExit(\"Index has no PEP 440 versions; schema may have changed\")","typeGuard":null,"tryCatchPattern":"try:\n    version = choose_version(versions, args.allow_prerelease, args.version)\nexcept ValueError as e:\n    if \"No parseable\" in str(e):\n        # Dump the raw index shape for diagnosis\n        print(json.dumps(index, indent=2)[:2000], file=sys.stderr)\n    raise","preventionTips":["Pin the packaging library version so PEP 440 parsing rules are stable.","Log the raw index shape when parse failures occur.","Monitor the NuGet v3-flatcontainer schema for structural changes."],"tags":["python","build-script","nuget","versioning","schema"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}