{"record":{"id":"79b796d0060f7e36","repo":"oraios/serena","slug":"error-extracting-archive","errorCode":null,"errorMessage":"Error extracting archive.","messagePattern":"Error extracting archive\\.","errorType":"exception","errorClass":"SolidLSPException","httpStatus":null,"severity":"error","filePath":"src/solidlsp/ls_utils.py","lineNumber":540,"sourceCode":"                FileUtils._extract_zip_archive(tmp_file_name_ungzipped, target_path)\n            elif archive_type == \"gz\":\n                target_directory = os.path.dirname(target_path) or \".\"\n                os.makedirs(target_directory, exist_ok=True)\n                temp_output_path = str(PurePath(target_directory, f\".{Path(target_path).name}.{uuid.uuid4().hex}.extract\"))\n                external_tmp_files.append(temp_output_path)\n                with gzip.open(tmp_file_name, \"rb\") as f_in, open(temp_output_path, \"wb\") as f_out:\n                    shutil.copyfileobj(f_in, f_out)\n                os.replace(temp_output_path, target_path)\n            elif archive_type == \"binary\":\n                target_directory = os.path.dirname(target_path) or \".\"\n                os.makedirs(target_directory, exist_ok=True)\n                shutil.move(tmp_file_name, target_path)\n            else:\n                log.error(f\"Unknown archive type '{archive_type}' for extraction\")\n                raise SolidLSPException(f\"Unknown archive type '{archive_type}'\")\n        except Exception as exc:\n            log.error(f\"Error extracting archive obtained from '{url}': {exc}\")\n            raise SolidLSPException(\"Error extracting archive.\") from exc\n        finally:\n            # cleaning up any temporary files outside the temporary directory\n            for tmp_file in external_tmp_files:\n                if os.path.exists(tmp_file):\n                    Path.unlink(Path(tmp_file))\n\n            # removing the temporary directory\n            if tmp_dir is not None:\n                shutil.rmtree(tmp_dir, ignore_errors=True)\n\n    @staticmethod\n    def calculate_sha256(file_path: str) -> str:\n        \"\"\"\n        Calculates the SHA256 checksum of a file.\n        \"\"\"\n        sha256_hash = hashlib.sha256()\n        with open(file_path, \"rb\") as input_file:\n            for chunk in iter(lambda: input_file.read(8192), b\"\"):","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/ls_utils.py#L522-L558","documentation":"Generic wrapper raised by download_and_extract_archive_verified: any exception during download extraction (including the unknown-archive-type error, IO errors, or corrupt archives) is caught and re-raised as SolidLSPException(\"Error extracting archive.\") with the original as __cause__. The real reason is in the log line 'Error extracting archive obtained from ...' and the chained exception.","triggerScenarios":"Any download_and_extract_archive_verified call (via download_to, _download_al_extension, _install_shellcheck_if_missing, _install_from_url, _download_nuget_package, _setup_runtime_dependencies) where extraction fails: unknown archive type, corrupt/partial download, disk full, permission denied on target path.","commonSituations":"Corporate proxy returning an HTML error page instead of the archive; interrupted download; installing a language server in a read-only install directory.","solutions":["Read the chained cause (__cause__) and the log message to find the underlying failure","Re-run the download after verifying network/proxy returns the real archive bytes","Check write permissions and free space on the target directory","If it is the unknown-type cause, fix the archive_type argument"],"exampleFix":"try:\n    download_to(url, dest)\nexcept SolidLSPException as e:\n    print(\"root cause:\", e.__cause__)","handlingStrategy":"try-catch","validationCode":"import zipfile, tarfile\nwith open(local_file, \"rb\") as f:\n    magic = f.read(4)\nif not (magic.startswith(b\"PK\") or magic.startswith(b\"\\x1f\\x8b\") or magic == b\"ustar\"):\n    raise ValueError(\"downloaded file is not a known archive format\")","typeGuard":null,"tryCatchPattern":"try:\n    download_and_extract_archive_verified(url, target, archive_type=\"zip\")\nexcept SolidLSPException as e:\n    logger.exception(\"extract failed, cause=%s\", e.__cause__)\n    # cleanup partial target dir, then retry or abort","preventionTips":["Always inspect e.__cause__ — this error hides the real failure","Verify download success (HTTP 200, content-type) before extraction","Ensure target directory exists and is writable","Validate checksum to catch truncated downloads early"],"tags":["download","archive","network"],"backgroundTag":"archive-extraction-failed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}