{"id":"2f06be88770cc9b1","repo":"pypa/pip","slug":"unexpected-file-name-derived-from-url-name-r","errorCode":null,"errorMessage":"Unexpected file name derived from URL: {name!r}","messagePattern":"Unexpected file name derived from URL: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/models/link.py","lineNumber":61,"sourceCode":"    ``os.path.basename`` drops any directory part, drive letter, or separator;\n    a ``.``, ``..``, or empty result is not a component and becomes ``\"\"``.\n    \"\"\"\n    name = os.path.basename(name)\n    if name in (\"\", os.curdir, os.pardir):\n        return PathComponent(\"\")\n\n    return PathComponent(name)\n\n\ndef as_path_component(name: str) -> PathComponent:\n    \"\"\"Like ``_to_path_component`` but reject the empty result.\n\n    Use where a file is about to be written, so a missing name is an error\n    rather than a silent fallback to the directory itself.\n    \"\"\"\n    component = _to_path_component(name)\n    if not component:\n        raise ValueError(f\"Unexpected file name derived from URL: {name!r}\")\n\n    return component\n\n\ndef join_within_directory(directory: str, component: PathComponent) -> str:\n    \"\"\"Join a single path ``component`` onto ``directory``.\n\n    ``component`` is a :data:`PathComponent`, so by type it has no separator and\n    is not a ``.`` or ``..`` reference; the result can never escape ``directory``.\n    Requiring ``PathComponent`` rather than ``str`` lets the type checker enforce\n    at the call site that the name was reduced to a safe component beforehand.\n    \"\"\"\n    return os.path.join(directory, component)\n\n\n# Order matters, earlier hashes have a precedence over later hashes for what\n# we will pick to use.\n_SUPPORTED_HASHES = (\"sha512\", \"sha384\", \"sha256\", \"sha224\", \"sha1\", \"md5\")","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/models/link.py#L43-L79","documentation":"Error \"Unexpected file name derived from URL: {name!r}\" thrown in pypa/pip.","triggerScenarios":"Thrown at src/pip/_internal/models/link.py:61 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}