{"record":{"id":"a5f25d6e7dd87d67","repo":"zylon-ai/private-gpt","slug":"unsupported-distribution-format-path-name","errorCode":null,"errorMessage":"Unsupported distribution format: {path.name}","messagePattern":"Unsupported distribution format: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/build_pip_index.py","lineNumber":66,"sourceCode":"    with tarfile.open(path, \"r:gz\") as archive:\n        pkg_info = next(\n            member\n            for member in archive.getmembers()\n            if member.name == \"PKG-INFO\" or member.name.endswith(\"/PKG-INFO\")\n        )\n        fileobj = archive.extractfile(pkg_info)\n        if fileobj is None:\n            raise ValueError(f\"Unable to read PKG-INFO from {path}\")\n        return parse_metadata(fileobj.read().decode())\n\n\ndef read_distribution(path: Path) -> Distribution:\n    if path.suffix == \".whl\":\n        name, requires_python = read_wheel_metadata(path)\n    elif path.name.endswith(\".tar.gz\"):\n        name, requires_python = read_sdist_metadata(path)\n    else:\n        raise ValueError(f\"Unsupported distribution format: {path.name}\")\n\n    return Distribution(\n        name=name,\n        normalized_name=normalize_name(name),\n        filename=path.name,\n        requires_python=requires_python,\n        sha256=hashlib.sha256(path.read_bytes()).hexdigest(),\n    )\n\n\ndef render_page(title: str, body: str) -> str:\n    return f\"\"\"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <title>{html.escape(title)}</title>\n  </head>","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/scripts/build_pip_index.py#L48-L84","documentation":"Raised by read_distribution in scripts/build_pip_index.py when a file in the package directory is neither a .whl wheel nor a .tar.gz sdist. The directory scan pre-filters by suffix, so in practice this triggers on files whose name ends with .whl or .tar.gz but whose exact suffix check/endswith evaluation differs (e.g. uppercase .WHL, .tar.bz2 renamed, or a directly-invoked read_distribution call on another path).","triggerScenarios":"Artifacts like package-1.0.WHL or package.tar.BZ2 present in the scanned dir in odd cases; calling read_distribution(Path('file.zip')) directly from code; a partially-downloaded file named package.tar.gz with unusual casing; build outputs like .whl~ editor backups passing an endswith check.","commonSituations":"Mixing old bz2/zip sdists into a directory meant for the simple index; manual artifact drops where the file was renamed rather than rebuilt; scripts reusing read_distribution on arbitrary paths.","solutions":["Convert or rebuild the artifact as a standard wheel (.whl) or gzip sdist (.tar.gz)","Rename to the canonical lowercase extensions only if the file genuinely has that format (verify with 'file' command)","Delete non-distribution files (zip, bz2, backups) from the scanned package dir","If calling read_distribution programmatically, pre-check path.suffix before calling"],"exampleFix":"# before\nls packages/\n# pkg-1.0.zip  pkg-1.0.tar.bz2\n\n# after: rebuild in standard formats\npython -m build\n# packages/ now contains pkg-1.0-py3-none-any.whl and pkg-1.0.tar.gz","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef is_supported_distribution(path: Path) -> bool:\n    return path.suffix == \".whl\" or path.name.endswith(\".tar.gz\")\n\n# filter before calling read_distribution","typeGuard":"def is_supported_distribution(path: Path) -> bool:\n    \"\"\"Type guard: path is a distribution format build_pip_index can read.\"\"\"\n    return path.suffix == \".whl\" or path.name.endswith(\".tar.gz\")","tryCatchPattern":"try:\n    dist = read_distribution(p)\nexcept ValueError as e:\n    if \"Unsupported distribution format\" in str(e):\n        logger.warning(\"skipping %s\", p.name)\n        continue\n    raise","preventionTips":["Standardize on lowercase .whl and .tar.gz outputs from a single build tool","Keep the package dir dedicated to distributions; move sources and zips elsewhere","Pre-filter directory listings with the same predicate the script uses before invoking it"],"tags":["packaging","pip-index","file-format","scripts"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}