OpenBMB/ChatDev · error · HTTPException

Failed to download session

Error message

Failed to download session

What it means

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'.

Solutions

  1. Inspect the server log 'Unexpected error during session download' for the actual traceback
  2. Verify /tmp is writable and has space for the temp zip
  3. Check ulimits/file descriptors if streaming large sessions
  4. Retry once transient IO issues are ruled out; report with logs if persistent
Defensive patterns

Strategy: retry

Validate before calling

assert os.access(tempfile.gettempdir(), os.W_OK), 'temp dir not writable'
assert shutil.disk_usage(tempfile.gettempdir()).free > MIN_FREE_BYTES

Try / catch

except HTTPError as e:
    if e.response.status_code == 500 and 'Failed to download session' in e.response.text:
        if looks_transient(env_check()): retry_with_backoff(download, attempts=3)
        else: collect_server_logs_and_report()

Prevention

When it happens

Trigger: GET download failing outside validation/zip steps: errors streaming the file response, temp file creation failure, background task setup errors, or unexpected IO problems.

Common situations: Temp directory not writable, disk exhaustion, file handle limits, or issues streaming large archives; often environmental rather than a code bug.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/746c9a4bde0a4f0a. Report an issue: GitHub.

Appendix: source

Thrown at server/routes/sessions.py:83

                zip_path.unlink()

        return FileResponse(
            path=zip_path,
            filename=f"{dir_name}.zip",
            media_type="application/zip",
            headers={"Content-Disposition": f"attachment; filename={dir_name}.zip"},
            background=BackgroundTask(cleanup_zip),
        )
    except ValidationError as exc:
        raise HTTPException(status_code=400, detail=str(exc))
    except ResourceNotFoundError:
        raise HTTPException(status_code=404, detail="Session directory not found")
    except HTTPException:
        raise
    except Exception as exc:
        logger = get_server_logger()
        logger.log_exception(exc, f"Unexpected error during session download: {session_id}")
        raise HTTPException(status_code=500, detail="Failed to download session")

View on GitHub (pinned to 4fb2db0ea9)