{"id":"a5c89b28def87051","repo":"pypa/pip","slug":"version-in-package-sdist-filename-r-is-not-consi","errorCode":null,"errorMessage":"Version in {package.sdist.filename!r} is not consistent with package version {str(package.version)!r}","messagePattern":"Version in (.+?) is not consistent with package version (.+?)","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":632,"sourceCode":"                    f\"package version {str(package.version)!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n        if package.sdist:\n            try:\n                name, version = parse_sdist_filename(package.sdist.filename)\n            except Exception as e:\n                raise PylockValidationError(\n                    f\"Invalid sdist filename {package.sdist.filename!r}\",\n                    context=\"sdist\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {package.sdist.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=\"sdist\",\n                )\n            if package.version and version != package.version:\n                raise PylockValidationError(\n                    f\"Version in {package.sdist.filename!r} is not consistent with \"\n                    f\"package version {str(package.version)!r}\",\n                    context=\"sdist\",\n                )\n        try:\n            for i, attestation_identity in enumerate(  # noqa: B007\n                package.attestation_identities or []\n            ):\n                _get_required(attestation_identity, str, \"kind\")\n        except Exception as e:\n            raise PylockValidationError(\n                e, context=f\"attestation-identities[{i}]\"\n            ) from e\n        return package\n\n    @property\n    def is_direct(self) -> bool:\n        return not (self.sdist or self.wheels)","sourceCodeStart":614,"sourceCodeEnd":650,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L614-L650","documentation":"Raised as PylockValidationError (pylock.py:632) when the version parsed from sdist.filename differs from the package.version field (only checked when package.version is set). It is the sdist analogue of the wheel-version consistency check at pylock.py:611, enforcing agreement between the archive name and the package metadata.","triggerScenarios":"A package entry with version='1.5.0' but sdist.filename='foo-1.4.0.tar.gz'. Triggered during Pylock.from_dict() / Pylock.validate() after a successful name match.","commonSituations":"Stale sdist filename left in the lock after a version bump; merging lock entries from two resolver runs that disagree on the version.","solutions":["Align the version segment of sdist.filename with package.version.","If the sdist filename is the source of truth, update package.version to match it.","Regenerate the lock file end-to-end so the sdist filename and version stay in sync."],"exampleFix":"# before\n[[packages]]\nname = \"foo\"\nversion = \"1.5.0\"\n[packages.sdist]\nfilename = \"foo-1.4.0.tar.gz\"\n\n# after\n[[packages]]\nname = \"foo\"\nversion = \"1.5.0\"\n[packages.sdist]\nfilename = \"foo-1.5.0.tar.gz\"","handlingStrategy":"validation","validationCode":"from pip._vendor.packaging.utils import parse_sdist_filename\nfrom pip._vendor.packaging.version import Version\ndef sdist_version_matches(package_version, sdist_filename):\n    _, ver = parse_sdist_filename(sdist_filename)\n    return (not package_version) or ver == Version(package_version)","typeGuard":"null","tryCatchPattern":"from pip._vendor.packaging.pylock import PylockValidationError\ntry:\n    Pylock.from_dict(d)\nexcept PylockValidationError as e:\n    handle_sdist_version_drift(e.context)","preventionTips":["Treat the version field and sdist filename as one unit.","Re-run the resolver after version bumps."],"tags":["pylock","validation","packaging","version-mismatch"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}