{"record":{"id":"ea8dc519a107f4f8","repo":"crewAIInc/crewAI","slug":"downloaded-archive-is-empty","errorCode":null,"errorMessage":"Downloaded archive is empty.","messagePattern":"Downloaded archive is empty\\.","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"lib/cli/src/crewai_cli/remote_template/main.py","lineNumber":225,"sourceCode":"        \"\"\"Download the default branch zipball for a repo.\"\"\"\n        url = f\"{GITHUB_API_BASE}/repos/{GITHUB_ORG}/{repo_name}/zipball\"\n        try:\n            response = httpx.get(url, follow_redirects=True, timeout=60)\n            response.raise_for_status()\n        except httpx.HTTPError as e:\n            click.secho(f\"Failed to download template: {e}\", fg=\"red\")\n            raise SystemExit(1) from e\n\n        return response.content\n\n    def _extract_zip(self, zip_bytes: bytes, dest: str) -> None:\n        \"\"\"Extract a GitHub zipball into dest, stripping the top-level directory.\"\"\"\n        with zipfile.ZipFile(io.BytesIO(zip_bytes)) as zf:\n            # GitHub zipballs have a single top-level dir like 'crewAIInc-fde-template_xxx-<sha>/'\n            members = zf.namelist()\n            if not members:\n                click.secho(\"Downloaded archive is empty.\", fg=\"red\")\n                raise SystemExit(1)\n\n            top_dir = members[0].split(\"/\")[0] + \"/\"\n\n            os.makedirs(dest, exist_ok=True)\n\n            for member in members:\n                if member == top_dir or not member.startswith(top_dir):\n                    continue\n\n                relative_path = member[len(top_dir) :]\n                if not relative_path:\n                    continue\n\n                target = os.path.realpath(os.path.join(dest, relative_path))\n                if not target.startswith(\n                    os.path.realpath(dest) + os.sep\n                ) and target != os.path.realpath(dest):\n                    continue","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/cli/src/crewai_cli/remote_template/main.py#L207-L243","documentation":"Raised by RemoteTemplateManager._extract_zip() when the downloaded GitHub zipball opens as a valid zip but contains zero entries (zf.namelist() is empty). It is a data-integrity guard before any files are written. The CLI prints the red message and exits 1; an empty destination directory may already have been created by a prior branch but no content is extracted.","triggerScenarios":"The zipball HTTP body was truncated or replaced by an empty/intercepted 200 response (transparent proxy, captive portal) that still decompresses as a zip; extremely rare GitHub-side artifact corruption. Genuine GitHub zipballs always contain at least the top-level directory entry.","commonSituations":"Corporate proxies mangling binary downloads; anti-virus stripping archive contents; flaky connections yielding a short body that happens to parse as an empty zip.","solutions":["Re-run `crewai template add <name>` — an empty archive is almost always a corrupted transfer.","If it repeats, download the zip manually (curl -L from github.com/crewAIInc/<repo>/archive/...) and verify `unzip -l` shows files.","Bypass or configure the intercepting proxy/AV if manual downloads are also empty.","Report upstream if the repo's default branch is genuinely empty on GitHub."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import io, zipfile\n\ndef is_usable_zipball(data: bytes) -> bool:\n    try:\n        with zipfile.ZipFile(io.BytesIO(data)) as zf:\n            return len(zf.namelist()) > 0\n    except zipfile.BadZipFile:\n        return False","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When downloading templates yourself, verify the zip has entries before extracting.","Compare the downloaded size with GitHub's reported size to detect truncated transfers.","An empty archive means corrupted transfer — re-download instead of investigating your local code."],"tags":["zip","download","data-integrity","template"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}