{"record":{"id":"0620dec94af7eda9","repo":"HKUDS/DeepTutor","slug":"both-name-and-server-url-are-required","errorCode":null,"errorMessage":"Both name and server_url are required.","messagePattern":"Both name and server_url are required\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":1896,"sourceCode":"    result = await probe_server(server_url, payload.api_key or \"\")\n    return result.to_dict()\n\n\n@router.post(\"/connect-lightrag-server\")\nasync def connect_lightrag_server_route(payload: ConnectLightRagServerRequest):\n    \"\"\"Connect an external LightRAG server as a retrieval-only knowledge base.\n\n    Re-probes server-side (never trusts the client's verdict), then registers a\n    pointer (``type: lightrag_server``). Retrieval is offloaded to the server's\n    ``/query`` endpoint — no copy, no local index.\n    \"\"\"\n    from deeptutor.services.rag.pipelines.lightrag_server.config import SUPPORTED_MODES\n    from deeptutor.services.rag.pipelines.lightrag_server.probe import probe_server\n\n    name = (payload.name or \"\").strip()\n    server_url = (payload.server_url or \"\").strip()\n    if not name or not server_url:\n        raise HTTPException(status_code=400, detail=\"Both name and server_url are required.\")\n\n    result = await probe_server(server_url, payload.api_key or \"\")\n    if not result.ok:\n        raise HTTPException(\n            status_code=400, detail=result.error or \"Could not connect to the LightRAG server.\"\n        )\n\n    search_mode = (payload.search_mode or \"\").strip().lower()\n    if search_mode and search_mode not in SUPPORTED_MODES:\n        search_mode = \"\"\n\n    try:\n        manager = get_kb_manager()\n        entry = manager.register_lightrag_server_kb(\n            name,\n            result.base_url,\n            api_key=payload.api_key or \"\",\n            search_mode=search_mode,","sourceCodeStart":1878,"sourceCodeEnd":1914,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L1878-L1914","documentation":"HTTP 400 from the LightRAG connect endpoint when either name or server_url is empty after stripping. Both fields are mandatory because the connection entry is keyed by name and must point at a reachable server URL.","triggerScenarios":"POST /connect-lightrag-server with a blank name, blank server_url, or both; typically a partially filled form or a payload built from unset config values.","commonSituations":"Frontend state not initialized for both fields, copy-paste leaving whitespace, or scripting the endpoint with placeholder empty strings.","solutions":["Provide both a non-empty name and server_url","Validate both fields in the client before calling connect","Use the probe endpoint first to confirm the URL, then connect"],"exampleFix":"// before\n{\"name\": \"\", \"server_url\": \"http://localhost:9621\"}\n// after\n{\"name\": \"main-rag\", \"server_url\": \"http://localhost:9621\"}","handlingStrategy":"validation","validationCode":"const name = payload.name?.trim();\nconst url = payload.server_url?.trim();\nif (!name || !url) throw new Error('Both name and server_url are required');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the probe endpoint first — it validates server_url and confirms reachability before connect"],"tags":["http-400","lightrag","validation","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}