python-poetry/poetry · error · InvalidSourceError
Missing [name] in source.
Error message
Missing [name] in source.
What it means
`InvalidSourceError` from `create_package_source` (factory.py:214-217) when a source entry in `[[tool.poetry.source]]` lacks a `name` key. The name is required to register the repository in the pool; without it Poetry cannot route dependency lookups.
Source
Thrown at src/poetry/factory.py:217
raise PoetryError(
"At least one source must not be configured as 'explicit'."
)
return pool
@classmethod
def create_package_source(
cls, source: dict[str, str], config: Config, disable_cache: bool = False
) -> HTTPRepository:
from poetry.repositories.exceptions import InvalidSourceError
from poetry.repositories.legacy_repository import LegacyRepository
from poetry.repositories.pypi_repository import PyPiRepository
from poetry.repositories.single_page_repository import SinglePageRepository
try:
name = source["name"]
except KeyError:
raise InvalidSourceError("Missing [name] in source.")
pool_size = config.installer_max_workers
if name.lower() == "pypi":
if "url" in source:
raise InvalidSourceError(
"The PyPI repository cannot be configured with a custom url."
)
return PyPiRepository(
config=config,
disable_cache=disable_cache,
pool_size=pool_size,
)
try:
url = source["url"]
except KeyError:
raise InvalidSourceError(f"Missing [url] in source {name!r}.")View on GitHub (pinned to 92b74dcfe3)
Solutions
- Add a `name` key to each `[[tool.poetry.source]]` entry.
- Ensure the key is lowercase `name` (TOML keys are case-sensitive).
- Validate the table with `poetry check`.
Example fix
# before [[tool.poetry.source]] url = "https://my.repo/simple/" # after [[tool.poetry.source]] name = "myrepo" url = "https://my.repo/simple/"
Defensive patterns
Strategy: validation
Validate before calling
sources = poetry.local_config.get("source", [])
for s in sources:
if "name" not in s:
raise SystemExit(f"source missing 'name': {s}") Type guard
def source_has_name(source: dict) -> bool:
return isinstance(source, dict) and isinstance(source.get("name"), str) and bool(source["name"].strip()) Prevention
- Always include `name = "..."` under `[[tool.poetry.source]]`.
- Use lowercase TOML keys (`name`, not `Name`).
- Validate pyproject.toml with `poetry check` after edits.
When it happens
Trigger: A source table with only `url = "..."`; a typo like `Name = "..."` (case-sensitive TOML key must be lowercase `name`); a partially commented source block.
Common situations: Hand-editing pyproject.toml; copy-pasting a source block and dropping the name line; mixing `[[tool.poetry.source]]` with a single `[tool.poetry.source]` table.
Related errors
- At least one source must not be configured as 'explicit'.
- This project requires Poetry {version_constraint}, but you a
- The PyPI repository cannot be configured with a custom url.
- Missing [url] in source {name!r}.
- Extra [{extra}] is not specified.
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/aa3e1d969eae6c2e.json.
Report an issue: GitHub.