{"id":"d0681550952f2d65","repo":"python-poetry/poetry","slug":"package-name-not-found","errorCode":null,"errorMessage":"Package [{name}] not found.","messagePattern":"Package \\[(.+?)\\] not found\\.","errorType":"exception","errorClass":"PackageNotFoundError","httpStatus":null,"severity":"error","filePath":"src/poetry/repositories/http_repository.py","lineNumber":581,"sourceCode":"    def _get_prefer_json_header(self) -> dict[str, str]:\n        # Prefer json, but accept anything for backwards compatibility.\n        # Although the more specific value should be preferred to the less specific one\n        # according to https://developer.mozilla.org/en-US/docs/Glossary/Quality_values,\n        # we add a quality value because some servers still prefer html without one.\n        return {\"Accept\": \"application/vnd.pypi.simple.v1+json, */*;q=0.1\"}\n\n    def _is_json_response(self, response: requests.Response) -> bool:\n        return (\n            response.headers.get(\"Content-Type\", \"\").split(\";\")[0].strip()\n            == \"application/vnd.pypi.simple.v1+json\"\n        )\n\n    def _get_page(self, name: NormalizedName) -> LinkSource:\n        response = self._get_response(\n            f\"/{name}/\", headers=self._get_prefer_json_header()\n        )\n        if not response:\n            raise PackageNotFoundError(f\"Package [{name}] not found.\")\n        if self._is_json_response(response):\n            return SimpleJsonPage(response.url, response.json())\n        return HTMLPage(response.url, response.text)\n\n    def log_age_filtered_versions(self, *, level: str, reset: bool) -> None:\n        if not self._age_filtered_versions:\n            return\n        self._log(\n            \"The following package versions were ignored\"\n            f\" due to solver.min-release-age={self._min_release_age}\",\n            level=level,\n        )\n        for name in sorted(self._age_filtered_versions):\n            versions = \", \".join(\n                str(v) for v in sorted(self._age_filtered_versions[name])\n            )\n            self._log(f\"{name}: {versions}\", level=level)\n        if reset:","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/repositories/http_repository.py#L563-L599","documentation":"Raised by HTTPRepository._get_page when the package's simple index page returns no response (http_repository.py:576-581). _get_response returns None on HTTP 404, 401, or 403 (http_repository.py:544-551), so this single message covers both genuine not-found and authentication/authorization failures — the code cannot distinguish them at this layer.","triggerScenarios":"repository.package() / package lookup for a name not present on the configured HTTP repository; or when the repository requires credentials that were not supplied/configured (401/403 collapsed to None).","commonSituations":"Private repository credentials missing (no http-basic config); package name typo; package exists on PyPI but the project only configured a private source; the source URL points at the wrong path.","solutions":["If the repository needs auth, configure credentials: `poetry config http-basic.<source> <user> <pass>` (or set POETRY_HTTP_BASIC_*).","Verify the package name spelling and that it actually exists on that index.","Confirm the [[tool.poetry.source]] URL is the correct simple-index base.","If the package is on PyPI, ensure a PyPI source is in the pool (it is by default) and not disabled."],"exampleFix":"// before\n[[tool.poetry.source]]\nname = \"private\"\nurl = \"https://repo.example.com/simple/\"\n// (no credentials configured -> 401 -> 'Package not found')\n// after\npoetry config http-basic.private myuser mytoken","handlingStrategy":"validation","validationCode":"# Confirm the package exists AND auth works before resolving\nresp = repository.session.get(f\"{repository._url}/{name}/\", timeout=10)\nif resp.status_code in (401, 403):\n    raise PermissionError(f\"auth missing for {repository.name}; configure http-basic.{repository.name}\")\nif resp.status_code == 404:\n    raise LookupError(f\"{name} not found on {repository.name}\")","typeGuard":null,"tryCatchPattern":"from poetry.repositories.exceptions import PackageNotFoundError\ntry:\n    page = repository._get_page(name)\nexcept PackageNotFoundError:\n    log.warning(\"%s not found on %s (check name and auth)\", name, repository.name)\n    raise","preventionTips":["Configure credentials once: `poetry config http-basic.<source> user pass`.","Use POETRY_HTTP_BASIC_<SOURCE>_USERNAME / _PASSWORD in CI.","Verify the exact package name against the index before adding it."],"tags":["repository","package-not-found","auth","http"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}