siyuan-note/siyuan · error

errors.New(msg) with Conf.Language(5) template: move…

Error message

errors.New(msg) with Conf.Language(5) template: move failure message shown to user

What it means

Box.Move renames a path inside a notebook via filelock.Rename (called from moveDoc). On failure it formats the localized template Conf.Language(5) with box name, source path and OS error, and returns errors.New(msg).

Solutions

  1. Read the OS error inside the message (e.g. 'no such file', 'file exists')
  2. Pick a destination name/path that does not already exist
  3. Retry after concurrent edits/syncs settle; ensure the source document still exists
  4. Avoid moving across mount points; keep the whole workspace on one filesystem
Defensive patterns

Strategy: validation

Validate before calling

if _, err := os.Stat(fromPath); err != nil { return errors.New("source document missing") }; if _, err := os.Stat(toPath); err == nil { return errors.New("destination already exists") }

Try / catch

if err := box.Move(oldPath, newPath); err != nil { showErrorToUser(err.Error()) }

Prevention

When it happens

Trigger: Renaming/moving a document when the source is missing, the destination already exists, or the filesystem cannot perform the rename (cross-device link, permission denied, path traversal already excluded by validation).

Common situations: Two clients moving the same doc concurrently; destination name already taken (duplicate title); data dir on a network mount where rename semantics differ; doc deleted externally before the move.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/b8965ed1bbecac52. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/box.go:520

	IncSync()
	return nil
}

func (box *Box) Move(oldPath, newPath string) error {
	if _, err := box.validateBoxPath(oldPath); err != nil {
		return err
	}
	if _, err := box.validateBoxPath(newPath); err != nil {
		return err
	}
	boxLocalPath := filepath.Join(util.DataDir, box.ID)
	fromPath := filepath.Join(boxLocalPath, oldPath)
	toPath := filepath.Join(boxLocalPath, newPath)

	if err := filelock.Rename(fromPath, toPath); err != nil {
		msg := fmt.Sprintf(Conf.Language(5), box.Name, fromPath, err)
		logging.LogErrorf("move [path=%s] in box [%s] failed: %s", fromPath, box.Name, err)
		return errors.New(msg)
	}

	if oldDir := path.Dir(oldPath); ast.IsNodeIDPattern(path.Base(oldDir)) {
		fromDir := filepath.Join(boxLocalPath, oldDir)
		if util.IsEmptyDir(fromDir) {
			filelock.Remove(fromDir)
		}
	}
	IncSync()
	return nil
}

func (box *Box) Remove(path string) error {
	if _, err := box.validateBoxPath(path); err != nil {
		return err
	}
	boxLocalPath := filepath.Join(util.DataDir, box.ID)
	filePath := filepath.Join(boxLocalPath, path)

View on GitHub (pinned to 8641553a1f)