HKUDS/DeepTutor · warning · HTTPException

server_url is required.

Error message

server_url is required.

What it means

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.

Source

Thrown at deeptutor/api/routers/knowledge.py:1877

class ConnectLightRagServerRequest(BaseModel):
    name: str
    server_url: str
    api_key: str = ""
    search_mode: str = ""


@router.post("/probe-lightrag-server")
async def probe_lightrag_server_route(payload: ProbeLightRagServerRequest):
    """Test-connect to an external LightRAG server before binding a KB to it.

    Returns the verdict (reachable? is it a LightRAG server? API key accepted?)
    so the UI can confirm before any registration happens. Creates nothing.
    """
    from deeptutor.services.rag.pipelines.lightrag_server.probe import probe_server

    server_url = (payload.server_url or "").strip()
    if not server_url:
        raise HTTPException(status_code=400, detail="server_url is required.")
    result = await probe_server(server_url, payload.api_key or "")
    return result.to_dict()


@router.post("/connect-lightrag-server")
async def connect_lightrag_server_route(payload: ConnectLightRagServerRequest):
    """Connect an external LightRAG server as a retrieval-only knowledge base.

    Re-probes server-side (never trusts the client's verdict), then registers a
    pointer (``type: lightrag_server``). Retrieval is offloaded to the server's
    ``/query`` endpoint — no copy, no local index.
    """
    from deeptutor.services.rag.pipelines.lightrag_server.config import SUPPORTED_MODES
    from deeptutor.services.rag.pipelines.lightrag_server.probe import probe_server

    name = (payload.name or "").strip()
    server_url = (payload.server_url or "").strip()
    if not name or not server_url:

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Supply a non-empty server_url (e.g. http://localhost:9621) in the request payload
  2. Add client-side required-field validation before submitting the probe
  3. Trim the input client-side and check for empty before sending

Example fix

// before
{"server_url": "   "}
// after
{"server_url": "http://localhost:9621"}
Defensive patterns

Strategy: validation

Validate before calling

const url = payload.server_url?.trim();
if (!url) throw new Error('server_url is required');
new URL(url); // also catches malformed URLs

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/3c9f31e2712817bb. Report an issue: GitHub.