{"record":{"id":"85c7b7bc292d87e0","repo":"nodejs/node","slug":"invalid-sdist-filename-filename","errorCode":null,"errorMessage":"Invalid sdist filename: {filename}","messagePattern":"Invalid sdist filename: (.+?)","errorType":"validation","errorClass":"InvalidSdistFilename","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/packaging/utils.py","lineNumber":161,"sourceCode":"    return (name, version, build, tags)\n\n\ndef parse_sdist_filename(filename: str) -> Tuple[NormalizedName, Version]:\n    if filename.endswith(\".tar.gz\"):\n        file_stem = filename[: -len(\".tar.gz\")]\n    elif filename.endswith(\".zip\"):\n        file_stem = filename[: -len(\".zip\")]\n    else:\n        raise InvalidSdistFilename(\n            f\"Invalid sdist filename (extension must be '.tar.gz' or '.zip'):\"\n            f\" {filename}\"\n        )\n\n    # We are requiring a PEP 440 version, which cannot contain dashes,\n    # so we split on the last dash.\n    name_part, sep, version_part = file_stem.rpartition(\"-\")\n    if not sep:\n        raise InvalidSdistFilename(f\"Invalid sdist filename: {filename}\")\n\n    name = canonicalize_name(name_part)\n\n    try:\n        version = Version(version_part)\n    except InvalidVersion as e:\n        raise InvalidSdistFilename(\n            f\"Invalid sdist filename (invalid version): {filename}\"\n        ) from e\n\n    return (name, version)\n","sourceCodeStart":143,"sourceCodeEnd":173,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/packaging/utils.py#L143-L173","documentation":"InvalidSdistFilename raised when, after stripping the extension, rpartition('-') finds no dash at all - meaning the stem cannot be split into name and version. PEP 440 versions cannot contain dashes, so a single dash is expected to separate name from version.","triggerScenarios":"An sdist filename like 'mypkg.tar.gz' (no version), or a stem with no dash separator between name and version.","commonSituations":"Malformed sdist names from non-standard build tools, or files renamed to drop the version component.","solutions":["Ensure sdist filenames follow the 'name-version.tar.gz' convention.","Regenerate the sdist with a PEP 517 backend that names files correctly.","Validate the presence of a dash-separated version before parsing."],"exampleFix":"# before\n# 'mypkg.tar.gz'\n\n# after\n# 'mypkg-1.0.0.tar.gz'","handlingStrategy":"validation","validationCode":"def sdist_has_version(filename: str) -> bool:\n    if filename.endswith('.tar.gz'):\n        stem = filename[:-len('.tar.gz')]\n    elif filename.endswith('.zip'):\n        stem = filename[:-len('.zip')]\n    else:\n        return False\n    return '-' in stem","typeGuard":null,"tryCatchPattern":"try:\n    name, ver = parse_sdist_filename(fn)\nexcept InvalidSdistFilename as e:\n    if 'Invalid sdist filename:' in str(e):\n        pass  # filename lacks name-version structure; skip or rename","preventionTips":["Keep sdist filenames in name-version.tar.gz form.","Regenerate sdists with a PEP 517 backend.","Do not strip version components when renaming."],"tags":["packaging","utils","sdist","filename"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}