{"record":{"id":"4eb423fc06450a47","repo":"HKUDS/DeepTutor","slug":"name-is-required","errorCode":null,"errorMessage":"name is required.","messagePattern":"name is required\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":1754,"sourceCode":"\n\nclass ConnectMarginNote4Request(BaseModel):\n    name: str\n    db_path: str = \"\"\n    description: str = \"\"\n\n\n@router.post(\"/connect-marginnote4\")\nasync def connect_marginnote4(payload: ConnectMarginNote4Request):\n    \"\"\"Register a connected MarginNote 4 library as a knowledge base.\n\n    Creates a ``type: marginnote4`` pointer so the MarginNote capability can\n    bind to it on turns where the user selects this KB. When ``db_path`` is\n    omitted the capability derives a default SQLite path from the KB name.\n    \"\"\"\n    name = (payload.name or \"\").strip()\n    if not name:\n        raise HTTPException(status_code=400, detail=\"name is required.\")\n    try:\n        manager = get_kb_manager()\n        entry = manager.register_marginnote4_kb(\n            name,\n            db_path=(payload.db_path or \"\").strip(),\n            description=(payload.description or \"\").strip(),\n        )\n        result = {\"status\": \"connected\", \"name\": name}\n        if entry.get(\"db_path\"):\n            result[\"db_path\"] = entry[\"db_path\"]\n        return result\n    except ValueError as e:\n        raise HTTPException(status_code=400, detail=str(e))\n    except Exception as e:\n        logger.error(f\"Error connecting MarginNote 4 library: {e}\")\n        raise HTTPException(status_code=500, detail=str(e))\n\n","sourceCodeStart":1736,"sourceCodeEnd":1772,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L1736-L1772","documentation":"Input-validation guard in POST /connect-marginnote4: the stripped name is empty. Pydantic only enforces that the field is present, so whitespace-only values reach this check. db_path and description are optional and not validated here; without db_path the MarginNote capability derives a default SQLite path from the name, so a valid name is mandatory.","triggerScenarios":"Thrown at deeptutor/api/routers/knowledge.py:1754 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-empty name for the MarginNote 4 library","Trim whitespace; blank-after-strip names are rejected"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","contentChangedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}