{"record":{"id":"3c9f31e2712817bb","repo":"HKUDS/DeepTutor","slug":"server-url-is-required","errorCode":null,"errorMessage":"server_url is required.","messagePattern":"server_url is required\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":1877,"sourceCode":"class ConnectLightRagServerRequest(BaseModel):\n    name: str\n    server_url: str\n    api_key: str = \"\"\n    search_mode: str = \"\"\n\n\n@router.post(\"/probe-lightrag-server\")\nasync def probe_lightrag_server_route(payload: ProbeLightRagServerRequest):\n    \"\"\"Test-connect to an external LightRAG server before binding a KB to it.\n\n    Returns the verdict (reachable? is it a LightRAG server? API key accepted?)\n    so the UI can confirm before any registration happens. Creates nothing.\n    \"\"\"\n    from deeptutor.services.rag.pipelines.lightrag_server.probe import probe_server\n\n    server_url = (payload.server_url or \"\").strip()\n    if not server_url:\n        raise HTTPException(status_code=400, detail=\"server_url is required.\")\n    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:","sourceCodeStart":1859,"sourceCodeEnd":1895,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L1859-L1895","documentation":"HTTP 400 raised by the LightRAG server probe endpoint when the request body has an empty or whitespace-only server_url. The route strips the field and rejects it before any network call, since probing requires a target URL.","triggerScenarios":"POST /probe-lightrag-server with server_url omitted, empty string, or only whitespace; or a client form that submits before the URL field is filled.","commonSituations":"UI validation gap letting an empty field through, defaulting server_url to an empty string in a config object, or trimming spaces in the field leaving it blank.","solutions":["Supply a non-empty server_url (e.g. http://localhost:9621) in the request payload","Add client-side required-field validation before submitting the probe","Trim the input client-side and check for empty before sending"],"exampleFix":"// before\n{\"server_url\": \"   \"}\n// after\n{\"server_url\": \"http://localhost:9621\"}","handlingStrategy":"validation","validationCode":"const url = payload.server_url?.trim();\nif (!url) throw new Error('server_url is required');\nnew URL(url); // also catches malformed URLs","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark server_url required in the form/UI and disable submit while empty"],"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"}