{"record":{"id":"85c56946573ff53f","repo":"lfnovo/open-notebook","slug":"error-executing-chat-str-e","errorCode":null,"errorMessage":"Error executing chat: {str(e)}","messagePattern":"Error executing chat: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/chat.py","lineNumber":388,"sourceCode":"        # Convert messages to response format\n        messages = extract_chat_messages(result.get(\"messages\", []))\n\n        return ExecuteChatResponse(session_id=request.session_id, messages=messages)\n    except NotFoundError:\n        raise HTTPException(status_code=404, detail=\"Session not found\")\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        # Log detailed error with context for debugging\n        logger.error(\n            f\"Error executing chat: {str(e)}\\n\"\n            f\"  Session ID: {request.session_id}\\n\"\n            f\"  Model override: {request.model_override}\\n\"\n            f\"  Traceback:\\n{traceback.format_exc()}\"\n        )\n        raise HTTPException(status_code=500, detail=f\"Error executing chat: {str(e)}\")\n\n\n@router.post(\"/chat/context\", response_model=BuildContextResponse)\nasync def build_context(request: BuildContextRequest):\n    \"\"\"Build context for a notebook based on context configuration.\"\"\"\n    try:\n        # Verify notebook exists\n        notebook = await Notebook.get(request.notebook_id)\n        if not notebook:\n            raise HTTPException(status_code=404, detail=\"Notebook not found\")\n\n        context_data, total_content = await build_notebook_context(\n            notebook, request.context_config\n        )\n\n        char_count = len(total_content)\n        estimated_tokens = token_count(total_content) if total_content else 0\n","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/chat.py#L370-L406","documentation":"500 from POST /chat/execute when the AI chat pipeline throws an unexpected exception. The handler logs session id, model override, and full traceback, then surfaces the message in the 500 detail.","triggerScenarios":"Missing/unconfigured AI provider credentials (no default model set), model API rate limits or auth failures inside the graph invocation, or context-building failures for the notebook's sources.","commonSituations":"No default model configured in settings; OpenAI/Anthropic API key invalid or expired; embeddings model unreachable; oversized context exceeding provider limits.","solutions":["Read the API log — the full traceback and session/model context are printed","Verify a default chat model is set and provider credentials are valid (check /api/providers and credentials endpoints)","Test with a smaller notebook context and an explicit model_override to isolate provider issues","Confirm the surreal-commands worker is running if the pipeline enqueues jobs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const providers = await (await fetch('/api/providers')).json();\nif (!providers.some(p => p.id === modelId)) throw new Error('Model not available');","typeGuard":null,"tryCatchPattern":"catch (e) { if (e.status === 500) showModelConfigHint(); logToConsole(e.detail); throw e; }","preventionTips":["Set and verify a default chat model","Keep provider credentials valid","Run the worker for async pipeline steps"],"tags":["http-500","ai-provider","chat-execute","traceback"],"backgroundTag":"ai-provider-request-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}