OpenBMB/ChatDev · error · ResourceNotFoundError
Session directory not found
Error message
Session directory not found
What it means
download_session builds WARE_HOUSE_DIR/session_{session_id} and raises ResourceNotFoundError when that directory is missing or not a directory. This becomes 404 via the outer handler (error 318).
Source
Thrown at server/routes/sessions.py:36
async def download_session(session_id: str):
try:
if not re.match(r"^[a-zA-Z0-9_-]+$", session_id):
logger = get_server_logger()
logger.log_security_event(
"INVALID_SESSION_ID_FORMAT",
f"Invalid session_id format: {session_id}",
details={"received_session_id": session_id},
)
raise ValidationError(
"Invalid session_id: only letters, digits, underscores, and hyphens are allowed",
field="session_id",
)
dir_name = f"session_{session_id}"
session_path = WARE_HOUSE_DIR / dir_name
if not session_path.exists() or not session_path.is_dir():
raise ResourceNotFoundError(
"Session directory not found",
resource_type="session",
resource_id=session_id,
)
with tempfile.NamedTemporaryFile(delete=False, suffix=".zip") as tmp_file:
zip_path = Path(tmp_file.name)
archive_base = zip_path.with_suffix("")
try:
shutil.make_archive(str(archive_base), "zip", root_dir=WARE_HOUSE_DIR, base_dir=dir_name)
except Exception as exc:
if zip_path.exists():
zip_path.unlink()
logger = get_server_logger()
logger.log_exception(exc, f"Failed to create zip archive for session: {session_id}")
raise HTTPException(status_code=500, detail="Failed to create zip archive")
View on GitHub (pinned to 4fb2db0ea9)
Solutions
- Confirm the session produced files (run a workflow) before downloading
- Check WARE_HOUSE_DIR on the server and volume mounts if containerized
- Look for cleanup jobs that removed session directories
- Re-run the session's workflow to regenerate the directory
Defensive patterns
Strategy: validation
Validate before calling
# server-side or via API: confirm the warehouse dir exists
# dir = WARE_HOUSE_DIR / f'session_{session_id}'
assert dir_exists_on_server(session_id), 'run the workflow first' Try / catch
except HTTPError as e:
if e.response.status_code == 404 and 'Session directory not found' in e.response.text:
rerun_workflow(session_id) # regenerate, then retry download Prevention
- Only download after the session has produced output
- Mount warehouse storage persistently in containers
When it happens
Trigger: GET download for a session whose warehouse directory was never created, was deleted, or the server's WARE_HOUSE_DIR points elsewhere (different host/volume).
Common situations: Downloading right after creating a session before any files are written; warehouse on ephemeral container storage lost on restart; WARE_HOUSE_DIR env misconfiguration across deployments.
Related errors
- Session not found
- Artifact stream not available
- Artifact file missing
- Failed to create zip archive
- Design file not found: {config_path}
AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27).
Data as JSON: /api/errors/3c0570b948e0ba5b.
Report an issue: GitHub.