siyuan-note/siyuan · error

Create notebook [%s] folder [%s] failed: %s

Error message

Create notebook [%s] folder [%s] failed: %s

What it means

In Box.Mkdir, after validateBoxPath, os.Mkdir(<DataDir>/<boxID>/path, 0755) is attempted; on failure it logs and returns errors.New(fmt.Sprintf(Conf.Language(6), box.Name, path, err)) — 'Create notebook [%s] folder [%s] failed: %s'. Mkdir is non-recursive: it requires the parent to exist and the target to not exist.

Source

Thrown at kernel/model/box.go:432

	}
	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 251596fc0d)

Solutions

  1. Use Box.MkdirAll (recursive) when intermediate directories may not exist.
  2. Check Box.Exist(path) first and skip if the folder is already there.
  3. Confirm write permission on the notebook's data directory.

Example fix

// before
if err := box.Mkdir(path); err != nil { return err }

// after: create parents and tolerate an existing folder
if box.Exist(path) { return nil }
if err := box.MkdirAll(path); err != nil { return err }
Defensive patterns

Strategy: validation

Validate before calling

// Use the recursive variant when the parent may not exist.
if !box.Exist(path) {
    return box.MkdirAll(path)
}

Try / catch

// Tolerate 'already exists' as success.
if err := box.Mkdir(path); err != nil && box.Exist(path) { return nil } else if err != nil { return err }

Prevention

When it happens

Trigger: A single-level folder creation inside a notebook (filetree/mkdir-style operations) where the parent directory is missing, the target already exists, permissions are insufficient, or the path is on a read-only volume.

Common situations: Creating a subfolder under a path whose parent was removed; recreating a folder that already exists; race with another client that created it first; read-only data dir.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/4b555cbde9fc8628. Report an issue: GitHub.