siyuan-note/siyuan · error

errors.New(msg) with Conf.Language(6) template: mkdir failur

Error message

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

What it means

Box.Mkdir creates a directory inside a notebook. On os.Mkdir failure it formats the localized template Conf.Language(6) with box name, path and the OS error, and returns it as the error. This is a user-facing message, not a typed error.

Source

Thrown at kernel/model/box.go:487

	}
	return
}

func (box *Box) Exist(p string) bool {
	if _, err := box.validateBoxPath(p); err != nil {
		return false
	}
	return filelock.IsExist(filepath.Join(util.DataDir, box.ID, p))
}

func (box *Box) Mkdir(path string) error {
	if _, err := box.validateBoxPath(path); err != nil {
		return err
	}
	if err := os.Mkdir(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {
		msg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)
		logging.LogErrorf("mkdir [path=%s] in box [%s] failed: %s", path, box.ID, err)
		return errors.New(msg)
	}
	IncSync()
	return nil
}

func (box *Box) MkdirAll(path string) error {
	if _, err := box.validateBoxPath(path); err != nil {
		return err
	}
	if err := os.MkdirAll(filepath.Join(util.DataDir, box.ID, path), 0755); err != nil {
		msg := fmt.Sprintf(Conf.Language(6), box.Name, path, err)
		logging.LogErrorf("mkdir all [path=%s] in box [%s] failed: %s", path, box.ID, err)
		return errors.New(msg)
	}
	IncSync()
	return nil
}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Read the OS error embedded in the message (path and reason are included)
  2. Verify <DataDir>/<boxID> exists and is writable
  3. Check the requested path for invalid characters for your OS
  4. Rebuild/reopen the notebook so the kernel refreshes its state
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := os.Stat(filepath.Join(util.DataDir, box.ID, parentOf(path))); err != nil { return errors.New("parent directory missing") }

Try / catch

if err := box.Mkdir(path); err != nil { showErrorToUser(err.Error()) } // message is already localized and user-facing

Prevention

When it happens

Trigger: Creating a document/folder when the target parent directory does not exist, lacks write permission, or the name collides with an existing file — after validateBoxPath passes.

Common situations: Notebook directory deleted externally while the UI still lists it; workspace on a read-only volume; filename with characters the OS rejects (e.g. ':' on Windows).

Understand the failure class

Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.

Related errors


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