Tencent/WeKnora · error
cannot move a folder into itself
Error message
cannot move a folder into itself
What it means
Raised in RenameOrMoveFolder when moving a folder whose target parent (newParentID) equals the folder's own ID — a folder cannot become its own child, which would create a cycle in the wiki folder tree. Structural-invariant guard.
Source
Thrown at internal/application/service/wiki_page.go:1645
}
name := folder.Name
if strings.TrimSpace(newName) != "" {
if name, err = validateFolderName(newName); err != nil {
return nil, err
}
}
targetParent := folder.ParentID
if moveParent {
targetParent = newParentID
}
parentPath := ""
depthBase := 0
if targetParent != types.WikiFolderRootID {
if targetParent == folder.ID {
return nil, errors.New("cannot move a folder into itself")
}
parent, err := s.repo.GetFolderByID(ctx, kbID, targetParent)
if err != nil {
return nil, err
}
if parent.Path == folder.Path || strings.HasPrefix(parent.Path, folder.Path+"/") {
return nil, errors.New("cannot move a folder into its own descendant")
}
parentPath = parent.Path
depthBase = parent.Depth
}
if existing, err := s.repo.GetChildFolderByName(ctx, kbID, targetParent, name); err == nil {
if existing.ID != folder.ID {
return nil, repository.ErrWikiFolderConflict
}
} else if !errors.Is(err, repository.ErrWikiFolderNotFound) {
return nil, errView on GitHub (pinned to 988cbb0330)
Solutions
- Choose a different target parent folder
- Skip the move when the client sends the folder's own id as parent
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/application/service/wiki_page.go:1645 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/65f917da3c66ede2.
Report an issue: GitHub.