{"record":{"id":"45faa045a8337cb2","repo":"lfnovo/open-notebook","slug":"strategy-model-ask-request-strategy-model-not-fo","errorCode":null,"errorMessage":"Strategy model {ask_request.strategy_model} not found","messagePattern":"Strategy model (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"api/routers/search.py","lineNumber":133,"sourceCode":"        from open_notebook.utils.error_classifier import classify_error\n\n        _, user_message = classify_error(e)\n        logger.error(f\"Error in ask streaming: {str(e)}\")\n        error_data = {\"type\": \"error\", \"message\": user_message}\n        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,","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/lfnovo/open-notebook/blob/a7de90d38aaf18ee85fd661854d35c11e44613e2/api/routers/search.py#L115-L151","documentation":"400 raised by the streaming /api/search/ask endpoint when the requested strategy model ID does not exist in the database (Model.get returned None). The strategy model is the LLM used to plan the ask pipeline.","triggerScenarios":"POST /api/search/ask with a strategy_model ID that is not a row in the models table — deleted model, stale ID cached in the client, or wrong ID pasted from another instance.","commonSituations":"Model deleted after the frontend saved its ID, restoring a DB backup without models, multi-instance setups where model IDs differ.","solutions":["Fetch current models via GET /api/models and use a valid strategy model ID","Clear stale model selections in the frontend (Settings → default models)","Create/restore the strategy model if it was accidentally deleted"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const models = await fetch('/api/models').then(r => r.json());\nconst valid = models.some(m => m.id === req.strategy_model);\nif (!valid) req.strategy_model = getDefault('strategy');","typeGuard":"const isKnownModelId = (id: string, models: Model[]) => models.some(m => m.id === id);","tryCatchPattern":"catch (e) { if (e.status === 400 && e.detail.includes('Strategy model')) refreshModelSelection(); }","preventionTips":["Refresh model list when ask fails with model-not-found","Persist default model IDs in settings, not in ad-hoc client state"],"tags":["ask","model-not-found","http-400","strategy-model"],"backgroundTag":"referenced-model-missing","analyzedSha":"a7de90d38aaf18ee85fd661854d35c11e44613e2","analyzedAt":"2026-08-27T02:39:58.166Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}