{"id":"aa3e1d969eae6c2e","repo":"python-poetry/poetry","slug":"missing-name-in-source","errorCode":null,"errorMessage":"Missing [name] in source.","messagePattern":"Missing \\[name\\] in source\\.","errorType":"validation","errorClass":"InvalidSourceError","httpStatus":null,"severity":"error","filePath":"src/poetry/factory.py","lineNumber":217,"sourceCode":"            raise PoetryError(\n                \"At least one source must not be configured as 'explicit'.\"\n            )\n\n        return pool\n\n    @classmethod\n    def create_package_source(\n        cls, source: dict[str, str], config: Config, disable_cache: bool = False\n    ) -> HTTPRepository:\n        from poetry.repositories.exceptions import InvalidSourceError\n        from poetry.repositories.legacy_repository import LegacyRepository\n        from poetry.repositories.pypi_repository import PyPiRepository\n        from poetry.repositories.single_page_repository import SinglePageRepository\n\n        try:\n            name = source[\"name\"]\n        except KeyError:\n            raise InvalidSourceError(\"Missing [name] in source.\")\n\n        pool_size = config.installer_max_workers\n\n        if name.lower() == \"pypi\":\n            if \"url\" in source:\n                raise InvalidSourceError(\n                    \"The PyPI repository cannot be configured with a custom url.\"\n                )\n            return PyPiRepository(\n                config=config,\n                disable_cache=disable_cache,\n                pool_size=pool_size,\n            )\n\n        try:\n            url = source[\"url\"]\n        except KeyError:\n            raise InvalidSourceError(f\"Missing [url] in source {name!r}.\")","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/factory.py#L199-L235","documentation":"`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.","triggerScenarios":"A source table with only `url = \"...\"`; a typo like `Name = \"...\"` (case-sensitive TOML key must be lowercase `name`); a partially commented source block.","commonSituations":"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.","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`."],"exampleFix":"# before\n[[tool.poetry.source]]\nurl = \"https://my.repo/simple/\"\n# after\n[[tool.poetry.source]]\nname = \"myrepo\"\nurl = \"https://my.repo/simple/\"","handlingStrategy":"validation","validationCode":"sources = poetry.local_config.get(\"source\", [])\nfor s in sources:\n    if \"name\" not in s:\n        raise SystemExit(f\"source missing 'name': {s}\")","typeGuard":"def source_has_name(source: dict) -> bool:\n    return isinstance(source, dict) and isinstance(source.get(\"name\"), str) and bool(source[\"name\"].strip())","tryCatchPattern":null,"preventionTips":["Always include `name = \"...\"` under `[[tool.poetry.source]]`.","Use lowercase TOML keys (`name`, not `Name`).","Validate pyproject.toml with `poetry check` after edits."],"tags":["sources","pyproject","factory"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}