{"id":"b84b9c1de3091899","repo":"pypa/pip","slug":"invalid-sdist-filename-package-sdist-filename-r","errorCode":null,"errorMessage":"Invalid sdist filename {package.sdist.filename!r}","messagePattern":"Invalid sdist filename (.+?)","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":621,"sourceCode":"                    context=f\"wheels[{i}]\",\n                ) from e\n            if name != package.name:\n                raise PylockValidationError(\n                    f\"Name in {wheel.filename!r} is not consistent with \"\n                    f\"package name {package.name!r}\",\n                    context=f\"wheels[{i}]\",\n                )\n            if package.version and version != package.version:\n                raise PylockValidationError(\n                    f\"Version in {wheel.filename!r} is not consistent with \"\n                    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 []","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L603-L639","documentation":"Raised as PylockValidationError (pylock.py:621) when parse_sdist_filename() throws while validating the sdist.filename field of a package during Package._from_dict. parse_sdist_filename expects a PEP 625/500-compliant sdist name of the form '<name>-<version>.tar.gz' (or .zip); anything else re-raises as this error with context='sdist'.","triggerScenarios":"A package entry has an sdist.filename that is not a valid sdist name, e.g. 'foo.tar.gz', 'foo-1.0.whl', 'foo-1.0.tar.bz2', or a path like '/srv/files/foo-1.0.tar.gz'. Triggered by Pylock.from_dict() or Pylock.validate().","commonSituations":"Lock generators that stored a bare artifact name, a wrong extension, or a full path in the filename field. Migrating a hand-written lock that confused the wheel and sdist filename formats.","solutions":["Correct sdist.filename to the full '<normalized-name>-<version>.tar.gz' form, matching PEP 625.","If the artifact is actually a wheel, move it under [[packages.wheels]] and remove the sdist entry.","Regenerate the lock file with a spec-compliant resolver."],"exampleFix":"# before\n[[packages]]\nname = \"foo\"\n[packages.sdist]\nfilename = \"foo.tar.gz\"\n\n# after\n[[packages]]\nname = \"foo\"\n[packages.sdist]\nfilename = \"foo-1.0.tar.gz\"","handlingStrategy":"validation","validationCode":"import re\nSDIST_RE = re.compile(r\"^(?P<name>[^-]+)-(?P<version>[^-]+)\\.(tar\\.gz|zip)$\")\ndef is_valid_sdist_filename(filename):\n    return bool(SDIST_RE.match(filename))","typeGuard":"null","tryCatchPattern":"from pip._vendor.packaging.pylock import PylockValidationError\ntry:\n    Pylock.from_dict(d)\nexcept PylockValidationError as e:\n    if 'sdist' in (e.context or ''):\n        flag_sdist_for_repair(e.context)","preventionTips":["Use packaging.utils.parse_sdist_filename to validate before constructing a Pylock.","Keep sdist filenames in PEP 625 normalized form."],"tags":["pylock","validation","packaging","sdist"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}