{"record":{"id":"746c9a4bde0a4f0a","repo":"OpenBMB/ChatDev","slug":"failed-to-download-session","errorCode":null,"errorMessage":"Failed to download session","messagePattern":"Failed to download session","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"server/routes/sessions.py","lineNumber":83,"sourceCode":"                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\"},\n            background=BackgroundTask(cleanup_zip),\n        )\n    except ValidationError as exc:\n        raise HTTPException(status_code=400, detail=str(exc))\n    except ResourceNotFoundError:\n        raise HTTPException(status_code=404, detail=\"Session directory not found\")\n    except HTTPException:\n        raise\n    except Exception as exc:\n        logger = get_server_logger()\n        logger.log_exception(exc, f\"Unexpected error during session download: {session_id}\")\n        raise HTTPException(status_code=500, detail=\"Failed to download session\")\n","sourceCodeStart":65,"sourceCodeEnd":84,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/server/routes/sessions.py#L65-L84","documentation":"The catch-all handler in download_session: any exception other than ValidationError, ResourceNotFoundError, or HTTPException is logged as 'Unexpected error during session download' and returned as HTTP 500 'Failed to download session'.","triggerScenarios":"GET download failing outside validation/zip steps: errors streaming the file response, temp file creation failure, background task setup errors, or unexpected IO problems.","commonSituations":"Temp directory not writable, disk exhaustion, file handle limits, or issues streaming large archives; often environmental rather than a code bug.","solutions":["Inspect the server log 'Unexpected error during session download' for the actual traceback","Verify /tmp is writable and has space for the temp zip","Check ulimits/file descriptors if streaming large sessions","Retry once transient IO issues are ruled out; report with logs if persistent"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"assert os.access(tempfile.gettempdir(), os.W_OK), 'temp dir not writable'\nassert shutil.disk_usage(tempfile.gettempdir()).free > MIN_FREE_BYTES","typeGuard":null,"tryCatchPattern":"except HTTPError as e:\n    if e.response.status_code == 500 and 'Failed to download session' in e.response.text:\n        if looks_transient(env_check()): retry_with_backoff(download, attempts=3)\n        else: collect_server_logs_and_report()","preventionTips":["Monitor writable temp space and file-descriptor limits on the server","Retry once for transient IO; escalate with server logs if it persists"],"tags":["http-500","session","internal-error"],"backgroundTag":"unexpected-server-error","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}