HKUDS/DeepTutor · error · HTTPException
Source not found
Error message
Source not found
What it means
Not-found guard (404) in POST /{kb_name}/files/move: the sanitized source path does not exist under the KB's raw/ directory, so there is nothing to move. Detection happens after _safe_join_raw, so traversal-safe paths that simply don't exist land here.
Solutions
- List the KB's files to confirm the source path
- Fix typos in the source path
- Restore the file/folder if it was deleted
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/knowledge.py:2422 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/b6523844bb97ea4c.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/knowledge.py:2422
@router.post("/{kb_name}/files/move")
async def move_kb_file(kb_name: str, payload: MoveFilePayload):
"""Move a file/folder between organizational folders (display only).
Moving never re-indexes: folders don't affect retrieval, so this is a pure
filesystem relocation under ``raw/``.
"""
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()}View on GitHub (pinned to 3e82f13042)