{"record":{"id":"351d0cf36d33cef6","repo":"unslothai/unsloth","slug":"folder-name-cannot-be-empty","errorCode":null,"errorMessage":"Folder name cannot be empty","messagePattern":"Folder name cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"studio/backend/core/rag/folder_sync.py","lineNumber":403,"sourceCode":"        return _update_folder(folder_id, name = name, auto_sync = auto_sync)\n\n\ndef _update_folder(\n    folder_id: str,\n    *,\n    name: str | None = None,\n    auto_sync: bool | None = None,\n) -> dict:\n    with closing(rag_db.get_connection()) as conn:\n        row = conn.execute(\n            \"SELECT status, delete_remove_index FROM linked_folders WHERE id=?\", (folder_id,)\n        ).fetchone()\n        if row is None or row[\"status\"] == \"retired\" or row[\"delete_remove_index\"] is not None:\n            raise KeyError(folder_id)\n        if name is not None:\n            clean_name = name.strip()\n            if not clean_name:\n                raise ValueError(\"Folder name cannot be empty\")\n            conn.execute(\n                \"UPDATE linked_folders SET name=?, updated_at=? WHERE id=?\",\n                (clean_name, _now(), folder_id),\n            )\n        if auto_sync is not None:\n            conn.execute(\n                \"UPDATE linked_folders SET auto_sync=?, updated_at=? WHERE id=?\",\n                (int(auto_sync), _now(), folder_id),\n            )\n        conn.commit()\n        return dict(\n            conn.execute(\"SELECT * FROM linked_folders WHERE id=?\", (folder_id,)).fetchone()\n        )\n\n\ndef _remove_snapshot(path: str | None) -> None:\n    if not path:\n        return","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/rag/folder_sync.py#L385-L421","documentation":"update_folder raises when a rename request supplies a name that is empty after strip(). The display name is the only user-editable field alongside auto_sync, and empty names would break folder listings, so they are rejected before the UPDATE statement runs.","triggerScenarios":"update_folder(folder_id, name=\"\"), name=\"   \", or a frontend sending name after trimming user input to nothing; note name=None skips the check entirely (only auto_sync is toggled).","commonSituations":"User clears the rename field and submits; whitespace-only paste; form validation done with .strip() on the client but the value submitted pre-strip as whitespace.","solutions":["Send a non-empty name after trimming, or omit name (pass None) to only update auto_sync.","Add required/minlength validation in the form so whitespace-only submits are blocked client-side.","If clearing the name should fall back to the directory basename, compute that fallback before calling update_folder."],"exampleFix":"# before\nupdate_folder(fid, name=\"   \")\n\n# after\nname = (new_name or \"\").strip() or Path(folder[\"path\"]).name\nupdate_folder(fid, name=name)","handlingStrategy":"validation","validationCode":"clean = (new_name or \"\").strip()\nif not clean:\n    raise ValidationError(\"name must be non-empty\")\nupdate_folder(folder_id, name=clean)","typeGuard":null,"tryCatchPattern":"try:\n    update_folder(fid, name=name)\nexcept ValueError as e:\n    if \"cannot be empty\" in str(e):\n        update_folder(fid, name=Path(registered_path).name)  # fallback to basename\n    else:\n        raise","preventionTips":["Trim and require non-empty names in the form before submit.","Pass name=None when only toggling auto_sync.","Fall back to the directory basename when a cleared name means 'reset'."],"tags":["validation","rag","folder-sync","ui"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}