{"record":{"id":"d299e2a2e6a8f055","repo":"reflex-dev/reflex","slug":"unable-to-write-the-downloaded-zip-to-disk-ose","errorCode":null,"errorMessage":"Unable to write the downloaded zip to disk {ose}","messagePattern":"Unable to write the downloaded zip to disk (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"reflex/utils/templates.py","lineNumber":149,"sourceCode":"        logger.error(f\"Failed to create temp directory for download: {ose}\")\n        raise SystemExit(1) from None\n\n    # Use httpx GET with redirects to download the zip file.\n    zip_file_path: Path = Path(temp_dir) / \"template.zip\"\n    try:\n        # Note: following redirects can be risky. We only allow this for reflex built templates at the moment.\n        response = net.get(template_url, follow_redirects=True)\n        logger.debug(f\"Server responded download request: {response}\")\n        response.raise_for_status()\n    except httpx.HTTPError as he:\n        logger.error(f\"Failed to download the template: {he}\")\n        raise SystemExit(1) from None\n    try:\n        zip_file_path.write_bytes(response.content)\n        logger.debug(f\"Downloaded the zip to {zip_file_path}\")\n    except OSError as ose:\n        logger.error(f\"Unable to write the downloaded zip to disk {ose}\")\n        raise SystemExit(1) from None\n\n    # Create a temp directory for the zip extraction.\n    try:\n        unzip_dir = Path(tempfile.mkdtemp())\n    except OSError as ose:\n        logger.error(f\"Failed to create temp directory for extracting zip: {ose}\")\n        raise SystemExit(1) from None\n\n    try:\n        zipfile.ZipFile(zip_file_path).extractall(path=unzip_dir)\n        # The zip file downloaded from github looks like:\n        # repo-name-branch/**/*, so we need to remove the top level directory.\n    except Exception as uze:\n        logger.error(f\"Failed to unzip the template: {uze}\")\n        raise SystemExit(1) from None\n\n    if len(subdirs := list(unzip_dir.iterdir())) != 1:\n        logger.error(f\"Expected one directory in the zip, found {subdirs}\")","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/reflex/utils/templates.py#L131-L167","documentation":"Raised by `create_config_init_app_from_remote_template` when the downloaded zip bytes cannot be written to disk (OSError from zip_file_path.write_bytes). The download itself succeeded, but persisting it to the temp directory failed, so initialization aborts.","triggerScenarios":"Template URL downloads fine but the temp directory fills up mid-write, loses permissions, or the filesystem errors (ENOSPC, EACCES, disk quota) while writing template.zip in the mkdtemp directory.","commonSituations":"Disk filling exactly during download (large template, low space); tmpfs size limits in containers; antivirus/lockers blocking writes on some platforms.","solutions":["Free disk space in TMPDIR (df -h) and retry init.","Point TMPDIR at a volume with more space: TMPDIR=$HOME/tmp reflex init.","Check for permission/quota issues on the temp volume."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import shutil\n\ndef disk_ok(path=\"/tmp\", need_mb=50) -> bool:\n    return shutil.disk_usage(path).free >= need_mb * 1024 * 1024","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure ample free disk space before downloading large templates.","Point TMPDIR to a volume with sufficient space in containers/CI."],"tags":["reflex","templates","disk-full","write-error","tempdir"],"backgroundTag":"disk-write-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}