{"id":"32d45b3caf151acc","repo":"python-poetry/poetry","slug":"hash-for-package-from-archive-archive-name-not","errorCode":null,"errorMessage":"Hash for {package} from archive {archive.name} not found in known hashes (was: {archive_hash})","messagePattern":"Hash for (.+?) from archive (.+?) not found in known hashes \\(was: (.+?)\\)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/installation/executor.py","lineNumber":809,"sourceCode":"            archive_hash = self._validate_archive_hash(archive, package)\n            self._hashes[package.name] = archive_hash\n\n    @staticmethod\n    def _validate_archive_hash(archive: Path, package: Package) -> str:\n        known_hashes = {f[\"hash\"] for f in package.files if f[\"file\"] == archive.name}\n        hash_types = {t.split(\":\")[0] for t in known_hashes}\n        hash_type = get_highest_priority_hash_type(hash_types, archive.name)\n\n        if hash_type is None:\n            raise RuntimeError(\n                f\"No usable hash type(s) for {package} from archive\"\n                f\" {archive.name} found (known hashes: {known_hashes!s})\"\n            )\n\n        archive_hash = f\"{hash_type}:{get_file_hash(archive, hash_type)}\"\n\n        if archive_hash not in known_hashes:\n            raise RuntimeError(\n                f\"Hash for {package} from archive {archive.name} not found in\"\n                f\" known hashes (was: {archive_hash})\"\n            )\n\n        return archive_hash\n\n    def _download_archive(\n        self,\n        operation: Install | Update,\n        url: str,\n        dest: Path,\n    ) -> None:\n        downloader = Downloader(\n            url, dest, self._authenticator, max_retries=self._max_retries\n        )\n        wheel_size = downloader.total_size\n\n        operation_message = self.get_operation_message(operation)","sourceCodeStart":791,"sourceCodeEnd":827,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/installation/executor.py#L791-L827","documentation":"Raised by Executor._validate_archive_hash at src/poetry/installation/executor.py:806-812 when the computed hash of the downloaded/cached archive (hash_type:get_file_hash(...)) is not in the set of known hashes recorded for that file in package.files. This is the core integrity check failing — the bytes Poetry fetched do not match the lock. RuntimeError.","triggerScenarios":"During install, for a package whose archive.name is listed in package.files, the actual bytes on disk hash to a value not present among the locked hashes. Triggered from _populate_hashes_dict → _validate_archive_hash.","commonSituations":"Corrupted download (network blip, truncated file), a poisoned HTTP cache, a mirror serving tampered artifacts, or a lock file from a different distribution of the same version.","solutions":["Clear Poetry's cache for the package: `poetry cache clear --all <CACHE_NAME>` (list via `poetry cache list`).","Re-download with caching disabled: `poetry install --no-cache`.","If the lock is stale relative to the upstream artifacts, regenerate: `poetry lock --no-cache --regenerate`.","If the hash mismatch persists, investigate whether a corporate proxy/mirror is rewriting artifacts."],"exampleFix":"# before\n$ poetry install\nRuntimeError: Hash for pkg ... not found in known hashes (was: sha256:deadbeef...)\n\n# after\n$ poetry cache clear --all pypi:cache\n$ poetry install --no-cache","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    executor.run(operations)\nexcept RuntimeError as e:\n    if 'not found in known hashes' in str(e):\n        run('poetry', 'cache', 'clear', '--all', cache_name, check=False)\n        executor.run(operations)  # one retry with a fresh download\n    raise","preventionTips":["Treat hash mismatches as integrity failures — investigate before retrying.","Use trusted indexes; avoid proxies that rewrite package bytes.","Keep caches modest in size to reduce stale-entry risk."],"tags":["checksum","integrity","hash","cache","installation","security"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}