{"record":{"id":"2bcc333c4aaf6b4e","repo":"lfnovo/open-notebook","slug":"answer-model-ask-request-answer-model-not-found","errorCode":null,"errorMessage":"Answer model {ask_request.answer_model} not found","messagePattern":"Answer model (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"api/routers/search.py","lineNumber":138,"sourceCode":"        yield f\"data: {json.dumps(error_data)}\\n\\n\"\n\n\n@router.post(\"/search/ask\")\nasync def ask_knowledge_base(ask_request: AskRequest):\n    \"\"\"Ask the knowledge base a question using AI models.\"\"\"\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(\n                status_code=400,\n                detail=f\"Answer model {ask_request.answer_model} not found\",\n            )\n        if not final_answer_model:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Final answer model {ask_request.final_answer_model} not found\",\n            )\n\n        # Check if embedding model is available\n        if not await model_manager.get_embedding_model():\n            raise HTTPException(\n                status_code=400,\n                detail=\"Ask feature requires an embedding model. Please configure one in the Models section.\",\n            )\n\n        # For streaming response\n        return StreamingResponse(","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/search.py#L120-L156","documentation":"400 from /api/search/ask when the answer model ID does not exist in the database. The answer model generates intermediate answers in the multi-step ask pipeline.","triggerScenarios":"POST /api/search/ask with an answer_model ID absent from the models table.","commonSituations":"Same as other model lookups: deleted model, stale client state, mismatched environment.","solutions":["List models via GET /api/models and pick a valid answer_model ID","Reset default model selections in settings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const valid = models.some(m => m.id === req.answer_model);\nif (!valid) req.answer_model = getDefault('answer');","typeGuard":"const isKnownModelId = (id: string, models: Model[]) => models.some(m => m.id === id);","tryCatchPattern":"catch (e) { if (e.status === 400 && e.detail.includes('Answer model')) refreshModelSelection(); }","preventionTips":["Validate all three model IDs before submitting ask requests"],"tags":["ask","model-not-found","http-400","answer-model"],"backgroundTag":"referenced-model-missing","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}