{"id":"42162f6081b4182c","repo":"python-poetry/poetry","slug":"unknown-metadata-version-dist-metadata-version","errorCode":null,"errorMessage":"Unknown metadata version: {dist.metadata_version}","messagePattern":"Unknown metadata version: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/poetry/inspection/info.py","lineNumber":273,"sourceCode":"\n    @classmethod\n    def _from_distribution(\n        cls, dist: pkginfo.BDist | pkginfo.SDist | pkginfo.Wheel\n    ) -> PackageInfo:\n        \"\"\"\n        Helper method to parse package information from a `pkginfo.Distribution`\n        instance.\n\n        :param dist: The distribution instance to parse information from.\n        \"\"\"\n        # If the METADATA version is greater than the highest supported version,\n        # pkginfo prints a warning and tries to parse the fields from the highest\n        # known version. Assuming that METADATA versions adhere to semver,\n        # this should be safe for minor updates.\n        if not dist.metadata_version or dist.metadata_version.split(\".\")[0] not in {\n            v.split(\".\")[0] for v in pkginfo.distribution.HEADER_ATTRS\n        }:\n            raise ValueError(f\"Unknown metadata version: {dist.metadata_version}\")\n\n        requirements = cls._requirements_from_distribution(dist)\n\n        info = cls(\n            name=dist.name,\n            version=dist.version,\n            summary=dist.summary,\n            requires_dist=requirements,\n            requires_python=dist.requires_python,\n        )\n\n        info._source_type = \"file\"\n        info._source_url = Path(dist.filename).resolve().as_posix()\n\n        return info\n\n    @classmethod\n    def _from_sdist_file(cls, path: Path) -> PackageInfo:","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/inspection/info.py#L255-L291","documentation":"Raised by PackageInfo._from_distribution at src/poetry/inspection/info.py:270-273 when the distribution's metadata_version is missing or its MAJOR component is not among the major versions pkginfo knows about (HEADER_ATTRS keys). pkginfo itself only warns on unknown versions, so Poetry adds a hard fail to avoid silently mis-parsing fields.","triggerScenarios":"Reading a wheel/sdist whose METADATA uses a newer metadata-spec major version than the installed `pkginfo` library supports, or whose metadata_version is blank. Triggered via PackageInfo.from_path → _from_distribution during inspection/resolution.","commonSituations":"A wheel built with a bleeding-edge setuptools producing Metadata-Version 2.2/2.3 while the installed pkginfo predates it; a corrupt archive; or an exotic packaging tool emitting an unusual metadata_version.","solutions":["Upgrade poetry (and its bundled pkginfo) to a release that supports the metadata version: `poetry self update` or reinstall in pipx.","Rebuild the wheel with a mainstream setuptools version to emit a widely-supported Metadata-Version.","Inspect the wheel's METADATA file and down-level the Metadata-Version header if you control the artifact."],"exampleFix":"# inspect before fixing\n$ unzip -p dist/pkg-1.0-py3-none-any.whl '*/METADATA' | head -1\nMetadata-Version: 2.3\n\n# fix: upgrade poetry so its pkginfo knows 2.3\n$ pipx upgrade poetry","handlingStrategy":"try-catch","validationCode":"import pkginfo\n\ndist = pkginfo.Wheel(str(path))  # or SDist / BDist\nknown_majors = {v.split('.')[0] for v in pkginfo.distribution.HEADER_ATTRS}\nif not dist.metadata_version or dist.metadata_version.split('.')[0] not in known_majors:\n    raise ValueError(f'Unsupported Metadata-Version: {dist.metadata_version}; upgrade pkginfo/poetry.')","typeGuard":null,"tryCatchPattern":"from poetry.inspection.info import PackageInfo\n\ntry:\n    info = PackageInfo.from_path(path)\nexcept ValueError as e:\n    if 'Unknown metadata version' in str(e):\n        raise SystemExit('Upgrade poetry (and bundled pkginfo) to read this wheel.') from e\n    raise","preventionTips":["Keep poetry up to date so its pkginfo supports current Metadata-Version.","Build wheels with mainstream setuptools to emit widely-supported Metadata-Version."],"tags":["metadata","pkginfo","inspection","versioning","wheel"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}