unslothai/unsloth · warning · ValueError
Folder name cannot be empty
Error message
Folder name cannot be empty
What it means
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.
Source
Thrown at studio/backend/core/rag/folder_sync.py:403
return _update_folder(folder_id, name = name, auto_sync = auto_sync)
def _update_folder(
folder_id: str,
*,
name: str | None = None,
auto_sync: bool | None = None,
) -> dict:
with closing(rag_db.get_connection()) as conn:
row = conn.execute(
"SELECT status, delete_remove_index FROM linked_folders WHERE id=?", (folder_id,)
).fetchone()
if row is None or row["status"] == "retired" or row["delete_remove_index"] is not None:
raise KeyError(folder_id)
if name is not None:
clean_name = name.strip()
if not clean_name:
raise ValueError("Folder name cannot be empty")
conn.execute(
"UPDATE linked_folders SET name=?, updated_at=? WHERE id=?",
(clean_name, _now(), folder_id),
)
if auto_sync is not None:
conn.execute(
"UPDATE linked_folders SET auto_sync=?, updated_at=? WHERE id=?",
(int(auto_sync), _now(), folder_id),
)
conn.commit()
return dict(
conn.execute("SELECT * FROM linked_folders WHERE id=?", (folder_id,)).fetchone()
)
def _remove_snapshot(path: str | None) -> None:
if not path:
returnView on GitHub (pinned to 203007d190)
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.
Example fix
# before update_folder(fid, name=" ") # after name = (new_name or "").strip() or Path(folder["path"]).name update_folder(fid, name=name)
Defensive patterns
Strategy: validation
Validate before calling
clean = (new_name or "").strip()
if not clean:
raise ValidationError("name must be non-empty")
update_folder(folder_id, name=clean) Try / catch
try:
update_folder(fid, name=name)
except ValueError as e:
if "cannot be empty" in str(e):
update_folder(fid, name=Path(registered_path).name) # fallback to basename
else:
raise Prevention
- 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'.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Linked folders support only knowledge-base and project scope
- The linked-folder scope no longer exists
- Linked folders in the same scope cannot overlap
- Path cannot be empty
- The managed RAG uploads folder cannot be linked
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/351d0cf36d33cef6.
Report an issue: GitHub.