lfnovo/open-notebook · error · HTTPException
Ask operation failed: {str(e)}
Error message
Ask operation failed: {str(e)} What it means
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'.
Source
Thrown at api/routers/search.py:174
return StreamingResponse(
stream_ask_response(
ask_request.question, strategy_model, answer_model, final_answer_model
),
media_type="text/event-stream",
headers={
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"X-Accel-Buffering": "no",
},
)
except HTTPException:
raise
except OpenNotebookError:
raise
except Exception as e:
logger.error(f"Error in ask endpoint: {str(e)}")
raise HTTPException(status_code=500, detail=f"Ask operation failed: {str(e)}")
@router.post("/search/ask/simple", response_model=AskResponse)
async def ask_knowledge_base_simple(ask_request: AskRequest):
"""Ask the knowledge base a question and return a simple response (non-streaming)."""
try:
# Validate models exist
strategy_model = await Model.get(ask_request.strategy_model)
answer_model = await Model.get(ask_request.answer_model)
final_answer_model = await Model.get(ask_request.final_answer_model)
if not strategy_model:
raise HTTPException(
status_code=400,
detail=f"Strategy model {ask_request.strategy_model} not found",
)
if not answer_model:
raise HTTPException(View on GitHub (pinned to a7de90d38a)
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
Defensive patterns
Strategy: try-catch
Validate before calling
for (const id of [strategy, answer, final]) {
if (!models.some(m => m.id === id)) throw new Error(`Model ${id} missing`);
} Try / catch
catch (e) {
if (e.status === 500 && /Ask operation failed/.test(e.detail)) showProviderDiagnostic(e.detail);
} Prevention
- Pre-validate models and embedding config
- Test provider keys after rotation
When it happens
Trigger: 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.
Common situations: Expired/invalid LLM API key, provider rate limits surfacing as raw exceptions, version drift between graph definitions and router code.
Related errors
- No answer generated
- Error executing transformation: {str(e)}
- Error fetching chat sessions: {str(e)}
- Error creating chat session: {str(e)}
- Error fetching session: {str(e)}
AI-assisted analysis of lfnovo/open-notebook@a7de90d38a (2026-08-27).
Data as JSON: /api/errors/9b8a4dc0b9f61648.
Report an issue: GitHub.