{"id":"83e4ecf41032c700","repo":"pypa/pip","slug":"name-in-package-sdist-filename-r-is-not-consiste","errorCode":null,"errorMessage":"Name in {package.sdist.filename!r} is not consistent with package name {package.name!r}","messagePattern":"Name in (.+?) is not consistent with package name (.+?)","errorType":"validation","errorClass":"PylockValidationError","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/packaging/pylock.py","lineNumber":626,"sourceCode":"                    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 []\n            ):\n                _get_required(attestation_identity, str, \"kind\")\n        except Exception as e:\n            raise PylockValidationError(\n                e, context=f\"attestation-identities[{i}]\"","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/packaging/pylock.py#L608-L644","documentation":"Raised as PylockValidationError (pylock.py:626) when the project name parsed from sdist.filename does not equal the package.name field after canonicalization. It enforces that the distribution name embedded in the sdist archive name matches the declared package name, mirroring the wheel-name check.","triggerScenarios":"A package entry where name='Foo' but sdist.filename='foo-bar-1.0.tar.gz', or any case where the normalized parsed name differs from the normalized package.name. Reached via Pylock.from_dict() / Pylock.validate().","commonSituations":"Renaming a project without updating the lock, or a resolver that canonicalized names inconsistently between the name field and the filename. Typos in manually authored locks.","solutions":["Make sdist.filename's name segment canonicalize to the same value as package.name.","If the filename is authoritative, update package.name to match (then re-normalize).","Regenerate the lock file to reconcile both fields automatically."],"exampleFix":"# before\n[[packages]]\nname = \"foo_bar\"\n[packages.sdist]\nfilename = \"foo-baz-1.0.tar.gz\"\n\n# after\n[[packages]]\nname = \"foo_bar\"\n[packages.sdist]\nfilename = \"foo_bar-1.0.tar.gz\"","handlingStrategy":"validation","validationCode":"from pip._vendor.packaging.utils import parse_sdist_filename, canonicalize_name\ndef sdist_name_matches(package_name, sdist_filename):\n    name, _ = parse_sdist_filename(sdist_filename)\n    return canonicalize_name(name) == canonicalize_name(package_name)","typeGuard":"null","tryCatchPattern":"from pip._vendor.packaging.pylock import PylockValidationError\ntry:\n    Pylock.from_dict(d)\nexcept PylockValidationError as e:\n    report_name_mismatch(e.context, e.message)","preventionTips":["Canonicalize package names with canonicalize_name before comparing.","Regenerate locks after any project rename."],"tags":["pylock","validation","packaging","name-mismatch"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}