pypa/pip · error · ValueError
Unexpected file name derived from URL: {name!r}
Error message
Unexpected file name derived from URL: {name!r} What it means
Error "Unexpected file name derived from URL: {name!r}" thrown in pypa/pip.
Source
Thrown at src/pip/_internal/models/link.py:61
``os.path.basename`` drops any directory part, drive letter, or separator;
a ``.``, ``..``, or empty result is not a component and becomes ``""``.
"""
name = os.path.basename(name)
if name in ("", os.curdir, os.pardir):
return PathComponent("")
return PathComponent(name)
def as_path_component(name: str) -> PathComponent:
"""Like ``_to_path_component`` but reject the empty result.
Use where a file is about to be written, so a missing name is an error
rather than a silent fallback to the directory itself.
"""
component = _to_path_component(name)
if not component:
raise ValueError(f"Unexpected file name derived from URL: {name!r}")
return component
def join_within_directory(directory: str, component: PathComponent) -> str:
"""Join a single path ``component`` onto ``directory``.
``component`` is a :data:`PathComponent`, so by type it has no separator and
is not a ``.`` or ``..`` reference; the result can never escape ``directory``.
Requiring ``PathComponent`` rather than ``str`` lets the type checker enforce
at the call site that the name was reduced to a safe component beforehand.
"""
return os.path.join(directory, component)
# Order matters, earlier hashes have a precedence over later hashes for what
# we will pick to use.
_SUPPORTED_HASHES = ("sha512", "sha384", "sha256", "sha224", "sha1", "md5")View on GitHub (pinned to d7d0d0a394)
When it happens
Trigger: Thrown at src/pip/_internal/models/link.py:61 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04).
Data as JSON: /data/errors/2f06be88770cc9b1.json.
Report an issue: GitHub.