{"record":{"id":"951519ef2450012b","repo":"oraios/serena","slug":"archive-not-found-self-archive-path","errorCode":null,"errorMessage":"Archive not found: {self.archive_path}","messagePattern":"Archive not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/util/zip.py","lineNumber":51,"sourceCode":"\n        :param archive_path: Path to the ZIP archive file\n        :param extract_dir: Directory where files will be extracted\n        :param verbose: Whether to log status messages\n        :param include_patterns: List of glob patterns for files to extract (None = all files)\n        :param exclude_patterns: List of glob patterns for files to skip\n        \"\"\"\n        self.archive_path = Path(archive_path)\n        self.extract_dir = Path(extract_dir)\n        self.verbose = verbose\n        self.include_patterns = include_patterns or []\n        self.exclude_patterns = exclude_patterns or []\n\n    def extract_all(self) -> None:\n        \"\"\"\n        Extract all files from the archive, skipping any that fail.\n        \"\"\"\n        if not self.archive_path.exists():\n            raise FileNotFoundError(f\"Archive not found: {self.archive_path}\")\n\n        if self.verbose:\n            log.info(f\"Extracting from: {self.archive_path} to {self.extract_dir}\")\n\n        with zipfile.ZipFile(self.archive_path, \"r\") as zip_ref:\n            for member in zip_ref.infolist():\n                if self._should_extract(member.filename):\n                    self._extract_member(zip_ref, member)\n                elif self.verbose:\n                    log.info(f\"Skipped: {member.filename}\")\n\n    def _should_extract(self, filename: str) -> bool:\n        \"\"\"\n        Determine whether a file should be extracted based on include/exclude patterns.\n\n        :param filename: The file name from the archive\n        :return: True if the file should be extracted\n        \"\"\"","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/util/zip.py#L33-L69","documentation":"Raised by ZipArchive.extract_all() when the archive path given to the extractor does not exist on disk. It is a plain FileNotFoundError wrapped with a clearer message naming the missing archive path, thrown before any zip reading starts.","triggerScenarios":"Calling extract_all() (directly or via test helpers for include/exclude patterns) when self.archive_path does not exist — i.e. the ZipFile path was constructed with a path to a file that was never created, was deleted, or the path string is wrong.","commonSituations":"Tests that build fixture archives in setUp but write them to a different directory than the ZipArchive was pointed at; a download/prepare step that silently failed so the .zip never materialized; typos or relative-vs-absolute path confusion; the archive deleted by a cleanup step or another test before extract_all runs.","solutions":["Check the archive_path in the error message exists (ls / os.path.exists) and fix the path passed to the ZipArchive constructor","Run or re-create the step that produces the archive (download/build/fixture setup) before calling extract_all()","In tests, ensure fixtures are created in setUp/tempdir with the same path handed to ZipArchive, and verify with assertTrue(archive_path.exists()) before extracting","Add an existence check or explicit error handling around extract_all() if the archive may legitimately be absent","Watch for tests running in parallel sharing a temp directory and deleting each other's archives; isolate per-test temp dirs"],"exampleFix":"// before\narchive = ZipArchive(zip_path, extract_dir)\narchive.extract_all()  # FileNotFoundError: Archive not found: ...\n\n// after\nif not zip_path.exists():\n    zip_path = build_fixture_zip(zip_path)  # create the archive first\narchive = ZipArchive(zip_path, extract_dir)\narchive.extract_all()","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef ensure_archive_ready(zip_path: Path) -> bool:\n    return zip_path.is_file() and zip_path.stat().st_size > 0\n\nif not ensure_archive_ready(zip_path):\n    raise RuntimeError(f\"Archive missing or empty before extraction: {zip_path}\")","typeGuard":"def is_existing_zip(path: Path) -> bool:\n    return path.is_file() and path.suffix == \".zip\" and path.stat().st_size > 0","tryCatchPattern":"try:\n    archive.extract_all()\nexcept FileNotFoundError as e:\n    logging.error(\"Archive unavailable: %s\", e)\n    create_or_download_archive(archive.archive_path)\n    archive.extract_all()","preventionTips":["Always assert the archive file exists immediately before extract_all()","Create fixtures in setUp with the exact path object handed to ZipArchive; use isolated per-test temp directories","Make any download/build step that produces the archive fail loudly instead of silently","Verify zip integrity (zipfile.is_zipfile) after creation and before extraction"],"tags":["file-not-found","zip","archive","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}