{"record":{"id":"f53a8f97463f4be4","repo":"headroomlabs-ai/headroom","slug":"failed-to-extract-archive-e","errorCode":null,"errorMessage":"Failed to extract archive: {e}","messagePattern":"Failed to extract archive: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"headroom/graph/installer.py","lineNumber":91,"sourceCode":"            raise ValueError(f\"Invalid URL: {url}\")\n\n        with urlopen(url, timeout=60) as response:  # noqa: S310\n            data = response.read()\n    except Exception as e:\n        raise RuntimeError(f\"Failed to download codebase-memory-mcp from {url}: {e}\") from e\n\n    # Extract binary from tar.gz\n    try:\n        with tarfile.open(fileobj=io.BytesIO(data), mode=\"r:gz\") as tar:\n            for member in tar.getmembers():\n                if member.name.endswith(CBM_BIN_NAME) or member.name == CBM_BIN_NAME:\n                    member.name = target_path.name\n                    tar.extract(member, CBM_BIN_DIR)\n                    break\n            else:\n                raise RuntimeError(\"codebase-memory-mcp binary not found in archive\")\n    except tarfile.TarError as e:\n        raise RuntimeError(f\"Failed to extract archive: {e}\") from e\n\n    # Make executable\n    target_path.chmod(target_path.stat().st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)\n\n    # Verify\n    try:\n        from headroom._subprocess import run\n\n        result = run(\n            [str(target_path), \"--version\"],\n            capture_output=True,\n            text=True,\n        )\n        if result.returncode == 0:\n            ver = result.stdout.strip()\n            logger.info(\"Installed: %s\", ver)\n        else:\n            logger.warning(\"Binary installed but version check failed\")","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/graph/installer.py#L73-L109","documentation":"Wraps tarfile.TarError raised while extracting the downloaded codebase-memory-mcp archive — i.e. the payload decompressed enough to open but failed during member extraction. Typical root causes: truncated download (connection cut mid-read so the gzip stream is short), corrupted bytes from a proxy, or a genuinely malformed tar built upstream. The chained TarError distinguishes this from the 'binary not found' (layout) and 'download failed' (transport) cases.","triggerScenarios":"urlopen succeeds but the response is cut off before the full body (aggressive 60s timeout on slow links, proxy buffer limits); disk-full during extraction; bit-flipped/corrupted cached download; upstream shipped a truncated release asset.","commonSituations":"Flaky networks in CI; downloads through filtering proxies that truncate large binaries; retries after partial failures reusing a bad cache.","solutions":["Simply retry the install — truncated transfers are usually transient; verify network stability first.","Check disk space in CBM_BIN_DIR and /tmp; extraction needs headroom for the binary.","Download the tar.gz manually, verify integrity (gzip -t file.tar.gz), and compare byte size to the GitHub asset size; if it differs, your proxy is truncating.","Place a manually verified binary on PATH to bypass the installer entirely."],"exampleFix":"# before\n# RuntimeError: Failed to extract archive: unexpected end of data\n\n# after: verify payload manually, then retry or bypass\n$ curl -fL -o cbm.tar.gz \"<GITHUB_RELEASE_URL>/<ver>/codebase-memory-mcp-linux-amd64.tar.gz\"\n$ gzip -t cbm.tar.gz && tar -xzf cbm.tar.gz -C ~/.local/bin/ && chmod +x ~/.local/bin/codebase-memory-mcp","handlingStrategy":"retry","validationCode":"import gzip\n\ndef gz_intact(path: str) -> bool:\n    try:\n        with open(path, \"rb\") as f:\n            gzip.GzipFile(fileobj=f).read()\n        return True\n    except (OSError, EOFError):\n        return False","typeGuard":null,"tryCatchPattern":"import time\n\nfor attempt in range(2):\n    try:\n        install_cbm()\n        break\n    except RuntimeError as e:\n        if \"Failed to extract\" in str(e) and attempt == 0:\n            time.sleep(3)  # truncated download — retry once\n            continue\n        raise","preventionTips":["Treat extraction failure as probable truncation: retry before debugging deeper.","Check disk space in the install dir before large downloads.","Verify downloaded bytes (gzip -t / size vs GitHub asset) when behind filtering proxies."],"tags":["installer","archive","corruption","network","extraction"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}