{"record":{"id":"aab88c83a1814bcc","repo":"OpenBMB/ChatDev","slug":"session-not-found","errorCode":null,"errorMessage":"Session not found","messagePattern":"Session not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"server/routes/artifacts.py","lineNumber":28,"sourceCode":"\nrouter = APIRouter()\n\nMAX_FILE_SIZE = 20 * 1024 * 1024  # 20 MB\n\n\ndef _split_csv(value: Optional[str]) -> Optional[List[str]]:\n    if not value:\n        return None\n    parts = [part.strip() for part in value.split(\",\")]\n    filtered = [part for part in parts if part]\n    return filtered or None\n\n\ndef _get_session_and_queue(session_id: str):\n    manager = get_websocket_manager()\n    session = manager.session_store.get_session(session_id)\n    if not session:\n        raise HTTPException(status_code=404, detail=\"Session not found\")\n    queue = session.artifact_queue\n    if queue is None:\n        raise HTTPException(status_code=404, detail=\"Artifact stream not available\")\n    return manager, queue\n\n\n@router.get(\"/api/sessions/{session_id}/artifact-events\")\nasync def poll_artifact_events(\n    session_id: str,\n    wait_seconds: float = Query(25.0, ge=0.0, le=60.0),\n    after: Optional[int] = Query(None, ge=0),\n    include_mime: Optional[str] = Query(None),\n    include_ext: Optional[str] = Query(None),\n    max_size: Optional[int] = Query(None, gt=0),\n    limit: int = Query(25, ge=1, le=100),\n):\n    manager, queue = _get_session_and_queue(session_id)\n    include_mime_list = _split_csv(include_mime)","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/server/routes/artifacts.py#L10-L46","documentation":"A session-scoped artifact endpoint looked up session_id in the websocket manager's session store and found no such session. All artifact routes delegate to _get_session_and_queue, which 404s when get_session returns falsy.","triggerScenarios":"GET /api/sessions/{session_id}/artifact-events or GET /api/sessions/{session_id}/artifacts/{artifact_id} with a session_id that was never created, was removed, or belongs to a server that restarted and lost in-memory state.","commonSituations":"Server restart wiped the in-memory session store while the client kept an old session_id; typo in session_id; session already cleaned up/expired.","solutions":["Verify the session still exists via the session listing API before polling artifacts","Re-create/reconnect the session to get a fresh session_id","Check for server restarts in logs that would clear in-memory sessions","URL-encode the session_id exactly as returned at creation"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# call the session listing/detail API first\nassert session_id in client.list_sessions(), 'session missing'","typeGuard":null,"tryCatchPattern":"try:\n    client.poll_artifact_events(session_id)\nexcept HTTPError as e:\n    if e.response.status_code == 404 and e.response.json()['detail'] == 'Session not found':\n        session_id = client.create_session()  # recover by recreating","preventionTips":["Handle 404 by recreating the session and re-running","Persist session IDs only alongside server generation/uptime awareness"],"tags":["http-404","session","artifacts"],"backgroundTag":"session-not-found","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}