{"record":{"id":"a843b0d7ad78fbc2","repo":"HKUDS/DeepTutor","slug":"str-e","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":1154,"sourceCode":"    try:\n        from deeptutor.services.config import get_kb_config_service\n        from deeptutor.services.rag.service import RAGService\n\n        providers = RAGService.list_providers()\n        kb_config = get_kb_config_service()\n        for provider in providers:\n            modes = provider.get(\"modes\") or []\n            if modes:\n                stored = kb_config.get_provider_mode(provider[\"id\"])\n                if stored in modes:\n                    provider[\"default_mode\"] = stored\n            # Whether an existing index for this engine can be linked in place\n            # (self-contained on disk). Drives the \"link existing folder\" UI.\n            provider[\"linkable\"] = provider.get(\"id\") in LINKABLE_PROVIDERS\n        return {\"providers\": providers}\n    except Exception as e:\n        logger.error(f\"Error getting RAG providers: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n\n\nclass ProviderModeUpdate(BaseModel):\n    \"\"\"Set an engine's global default retrieval mode (from its engine card).\"\"\"\n\n    mode: str\n\n\n@router.put(\"/rag-providers/{provider}/mode\")\nasync def set_rag_provider_mode(provider: str, payload: ProviderModeUpdate):\n    \"\"\"Persist the default retrieval mode for a mode-aware engine.\n\n    The mode must be one the engine supports; a KB's own ``search_mode`` still\n    overrides this per-KB default.\n    \"\"\"\n    from deeptutor.services.config import get_kb_config_service\n    from deeptutor.services.rag.service import RAGService\n","sourceCodeStart":1136,"sourceCodeEnd":1172,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L1136-L1172","documentation":"Top-level catch-all in the public get_rag_providers handler: any unexpected exception while assembling the provider list (config loading, registry import, provider status probing) is logged and re-raised as HTTP 500 with the original message. It signals a server-side bug or broken environment, not a client mistake.","triggerScenarios":"GET on the RAG providers listing endpoint when provider discovery throws — broken settings JSON, an import error inside a pipeline module, or an exception from a provider status helper.","commonSituations":"Corrupted data/user/settings file; partially installed extras causing ImportError during provider registry build; provider config helpers raising on malformed values after a version upgrade.","solutions":["Check the server logs — the line 'Error getting RAG providers' includes the underlying exception","Validate/repair the settings JSON under data/user/settings/","Reinstall missing extras (graphrag/lightrag) if the log shows ImportError","Report upstream with the stack trace if the cause is inside deeptutor itself"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try: providers = client.get('/api/v1/knowledge/rag/providers').json()\nexcept HTTPError as e:\n    if e.response.status_code == 500: log_server_error(); alert_admin(e.response.json()['detail'])","preventionTips":["Keep server logs accessible; the 500 detail mirrors the logged exception","Validate settings JSON files on deploy","Install all provider extras consistently to avoid ImportErrors during discovery"],"tags":["rag","providers","http-500","unexpected-exception"],"backgroundTag":"internal-server-error","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}