zylon-ai/private-gpt · error · ValueError

Distribution metadata is missing Name

Error message

Distribution metadata is missing Name

What it means

Raised by parse_metadata in scripts/build_pip_index.py when parsing a wheel's METADATA or an sdist's PKG-INFO email-header blob yields no 'Name:' field. Every compliant Python distribution must carry Name in its core metadata; if it is absent the file is malformed or truncated, and the index builder cannot attribute the artifact to a project, so it aborts.

Source

Thrown at scripts/build_pip_index.py:35

@dataclass(frozen=True)
class Distribution:
    name: str
    normalized_name: str
    filename: str
    requires_python: str | None
    sha256: str


def normalize_name(name: str) -> str:
    return re.sub(r"[-_.]+", "-", name).lower()


def parse_metadata(payload: str) -> tuple[str, str | None]:
    metadata = Parser().parsestr(payload)
    name = metadata["Name"]
    if not name:
        raise ValueError("Distribution metadata is missing Name")
    return name, metadata.get("Requires-Python")


def read_wheel_metadata(path: Path) -> tuple[str, str | None]:
    with zipfile.ZipFile(path) as archive:
        metadata_name = next(
            name for name in archive.namelist() if name.endswith(".dist-info/METADATA")
        )
        return parse_metadata(archive.read(metadata_name).decode())


def read_sdist_metadata(path: Path) -> tuple[str, str | None]:
    with tarfile.open(path, "r:gz") as archive:
        pkg_info = next(
            member
            for member in archive.getmembers()
            if member.name == "PKG-INFO" or member.name.endswith("/PKG-INFO")
        )

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Rebuild the distribution with a standard backend (hatchling, setuptools, uv build) so METADATA/PKG-INFO are complete
  2. Inspect the artifact: unzip -p file.whl '*.dist-info/METADATA' | head and confirm a 'Name:' line exists
  3. Delete the malformed artifact from the package dir so the index build can proceed with valid ones
  4. If the file is corrupted (size 0 / truncated), re-fetch or rebuild it

Example fix

# before: wheel METADATA contains only
Metadata-Version: 2.1

# after: rebuild properly
uv build   # or: python -m build
unzip -p dist/*.whl '*.dist-info/METADATA' | grep '^Name:'
Defensive patterns

Strategy: validation

Validate before calling

import zipfile

def wheel_has_name(path: str) -> bool:
    with zipfile.ZipFile(path) as z:
        meta = next((n for n in z.namelist() if n.endswith(".dist-info/METADATA")), None)
        if meta is None:
            return False
        return any(line.startswith(b"Name:") for line in z.read(meta).splitlines())

Type guard

null

Try / catch

try:
    read_distribution(p)
except ValueError as e:
    logger.warning("skipping malformed artifact %s: %s", p.name, e)
    # continue with remaining artifacts instead of aborting the whole index build

Prevention

When it happens

Trigger: A hand-built wheel whose METADATA file lacks the Name header; a truncated/corrupted artifact produced by an interrupted build; a METADATA file with a BOM or wrong encoding that makes email.parser miss the header; an intentionally minimal test artifact passed to the script.

Common situations: Manually crafted or patched wheels for air-gapped pip indexes; artifacts produced by nonstandard build tools; partial uploads where the file was cut off; dist-info directory named correctly but populated with a stub METADATA.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/e62f05973d0dfa16. Report an issue: GitHub.