{"record":{"id":"9b8a4dc0b9f61648","repo":"lfnovo/open-notebook","slug":"ask-operation-failed-str-e","errorCode":null,"errorMessage":"Ask operation failed: {str(e)}","messagePattern":"Ask operation failed: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"api/routers/search.py","lineNumber":174,"sourceCode":"        return StreamingResponse(\n            stream_ask_response(\n                ask_request.question, strategy_model, answer_model, final_answer_model\n            ),\n            media_type=\"text/event-stream\",\n            headers={\n                \"Cache-Control\": \"no-cache\",\n                \"Connection\": \"keep-alive\",\n                \"X-Accel-Buffering\": \"no\",\n            },\n        )\n\n    except HTTPException:\n        raise\n    except OpenNotebookError:\n        raise\n    except Exception as e:\n        logger.error(f\"Error in ask endpoint: {str(e)}\")\n        raise HTTPException(status_code=500, detail=f\"Ask operation failed: {str(e)}\")\n\n\n@router.post(\"/search/ask/simple\", response_model=AskResponse)\nasync def ask_knowledge_base_simple(ask_request: AskRequest):\n    \"\"\"Ask the knowledge base a question and return a simple response (non-streaming).\"\"\"\n    try:\n        # Validate models exist\n        strategy_model = await Model.get(ask_request.strategy_model)\n        answer_model = await Model.get(ask_request.answer_model)\n        final_answer_model = await Model.get(ask_request.final_answer_model)\n\n        if not strategy_model:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Strategy model {ask_request.strategy_model} not found\",\n            )\n        if not answer_model:\n            raise HTTPException(","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/search.py#L156-L192","documentation":"Catch-all 500 from the streaming ask endpoint for exceptions outside HTTPException/OpenNotebookError — e.g. LangGraph pipeline crashes, provider API failures, or streaming setup errors. Logged as 'Error in ask endpoint'.","triggerScenarios":"POST /api/search/ask when graph invocation or StreamingResponse setup raises an unexpected exception: bad provider credentials at call time, LLM provider outage, malformed graph state.","commonSituations":"Expired/invalid LLM API key, provider rate limits surfacing as raw exceptions, version drift between graph definitions and router code.","solutions":["Check logs for 'Error in ask endpoint' to get the real exception","Verify the LLM provider API key and connectivity for all three selected models","Test each model individually via a chat completion call","Update to matching versions if recently upgraded"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for (const id of [strategy, answer, final]) {\n  if (!models.some(m => m.id === id)) throw new Error(`Model ${id} missing`);\n}","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e.status === 500 && /Ask operation failed/.test(e.detail)) showProviderDiagnostic(e.detail);\n}","preventionTips":["Pre-validate models and embedding config","Test provider keys after rotation"],"tags":["ask","http-500","llm-provider","streaming"],"backgroundTag":"llm-provider-request-failed","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}