{"record":{"id":"935028ad53af7d0f","repo":"OpenBMB/ChatDev","slug":"failed-to-create-zip-archive","errorCode":null,"errorMessage":"Failed to create zip archive","messagePattern":"Failed to create zip archive","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"server/routes/sessions.py","lineNumber":53,"sourceCode":"        if not session_path.exists() or not session_path.is_dir():\n            raise ResourceNotFoundError(\n                \"Session directory not found\",\n                resource_type=\"session\",\n                resource_id=session_id,\n            )\n\n        with tempfile.NamedTemporaryFile(delete=False, suffix=\".zip\") as tmp_file:\n            zip_path = Path(tmp_file.name)\n\n        archive_base = zip_path.with_suffix(\"\")\n        try:\n            shutil.make_archive(str(archive_base), \"zip\", root_dir=WARE_HOUSE_DIR, base_dir=dir_name)\n        except Exception as exc:\n            if zip_path.exists():\n                zip_path.unlink()\n            logger = get_server_logger()\n            logger.log_exception(exc, f\"Failed to create zip archive for session: {session_id}\")\n            raise HTTPException(status_code=500, detail=\"Failed to create zip archive\")\n\n        logger = get_server_logger()\n        logger.info(\n            \"Session download prepared\",\n            log_type=LogType.WORKFLOW,\n            session_id=session_id,\n            archive_path=str(zip_path),\n        )\n\n        def cleanup_zip():\n            if zip_path.exists():\n                zip_path.unlink()\n\n        return FileResponse(\n            path=zip_path,\n            filename=f\"{dir_name}.zip\",\n            media_type=\"application/zip\",\n            headers={\"Content-Disposition\": f\"attachment; filename={dir_name}.zip\"},","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/server/routes/sessions.py#L35-L71","documentation":"shutil.make_archive threw while zipping the session directory; the partial zip is unlinked, the failure is logged, and HTTP 500 'Failed to create zip archive' is returned.","triggerScenarios":"GET download when the session directory contains unreadable/permission-restricted files, disappears mid-zip, or disk space for the temp zip is exhausted.","commonSituations":"Concurrent deletion of the session dir during download; permission mismatches when files were written by another user; full /tmp or warehouse volume.","solutions":["Check the logged exception 'Failed to create zip archive for session' for the root cause","Verify read permissions on all files under the session directory","Free disk space on the temp/warehouse volume","Avoid deleting the session while a download is in flight"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# pre-flight checks before download\nassert disk_space(temp_dir, estimate=session_size(session_id))\nassert readable(session_dir_on_server(session_id))","typeGuard":null,"tryCatchPattern":"except HTTPError as e:\n    if e.response.status_code == 500 and 'zip' in e.response.text:\n        wait_for_no_concurrent_cleanup(); retry_download(session_id)","preventionTips":["Keep disk space on temp/warehouse volumes","Don't delete session directories during downloads"],"tags":["http-500","zip","filesystem","session"],"backgroundTag":"archive-creation-failed","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}