HKUDS/DeepTutor · error · HTTPException
Cannot move a folder into itself
Error message
Cannot move a folder into itself
What it means
Validation guard in POST /{kb_name}/files/move: the destination folder is the source folder itself or lies inside it, so the move would place a folder within its own subtree — an invalid/recursive relocation that the endpoint rejects instead of performing.
Solutions
- Choose a destination folder outside the source subtree
- Move the folder to a sibling or the raw/ root instead
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/knowledge.py:2431 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/4de1d6b0a19f65a8.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/knowledge.py:2431
manager, kb_name, _ = _writable_kb(kb_name)
_assert_kb_writable_or_409(kb_name, _load_kb_entry_or_404(manager, kb_name))
raw_dir = manager.get_knowledge_base_path(kb_name) / "raw"
source_rel = _sanitize_rel_subdir(payload.source)
if not source_rel:
raise HTTPException(status_code=400, detail="Source path is required")
src = _safe_join_raw(raw_dir, source_rel)
if not src.exists():
raise HTTPException(status_code=404, detail="Source not found")
dest_folder = _sanitize_rel_subdir(payload.dest_folder)
dest_dir = _safe_join_raw(raw_dir, dest_folder) if dest_folder else raw_dir.resolve()
dest = dest_dir / src.name
if dest.resolve() == src.resolve():
return {"status": "ok", "path": source_rel}
if src.is_dir() and dest_dir.resolve().is_relative_to(src.resolve()):
raise HTTPException(status_code=400, detail="Cannot move a folder into itself")
if dest.exists():
raise HTTPException(
status_code=409,
detail=f"'{src.name}' already exists in the target folder",
)
dest_dir.mkdir(parents=True, exist_ok=True)
shutil.move(str(src), str(dest))
return {"status": "ok", "path": dest.relative_to(raw_dir.resolve()).as_posix()}
@router.get("/{kb_name}/file-preview-text/{filename:path}")
async def serve_kb_raw_file_text_preview(kb_name: str, filename: str):
"""Serve extracted plain text for a raw KB document preview."""
target = _resolve_kb_raw_file_or_404(kb_name, filename)
try:
text = extract_text_from_path(
target,View on GitHub (pinned to 3e82f13042)