siyuan-note/siyuan · error

0

0

Error message

Conf.Language(0)

What it means

Returned by model.RenameBox when Conf.Box(boxID) returns nil, i.e. no notebook configuration exists for the given boxID. The localized message is Conf.Language(0): "Query notebook failed" — a generic 'notebook not found' error used across the kernel when a box lookup fails.

Solutions

  1. Fetch the current notebook list via GET /api/notebook/lsNotebooks and use a fresh, existing ID
  2. Confirm you are talking to the correct workspace/kernel instance (port, --workspace flag)
  3. If the notebook was deleted, recreate it (createNotebook) instead of renaming the old ID

Example fix

// before
err := model.RenameBox(boxID, newName) // boxID no longer exists

// after
notebooks, _ := ListNotebooks()
for _, nb := range notebooks {
    if nb.ID == boxID {
        return model.RenameBox(boxID, newName)
    }
}
return errors.New("notebook not found: " + boxID)
Defensive patterns

Strategy: validation

Validate before calling

notebooks, err := model.ListNotebooks()
if err != nil {
    return err
}
found := false
for _, nb := range notebooks {
    if nb.ID == boxID {
        found = true
        break
    }
}
if !found {
    return fmt.Errorf("notebook %s does not exist", boxID)
}
return model.RenameBox(boxID, newName)

Try / catch

if err := model.RenameBox(boxID, newName); err != nil {
    if err.Error() == Conf.Language(0) {
        // notebook missing: refresh IDs and inform user instead of retrying blindly
    }
}

Prevention

When it happens

Trigger: POST /api/notebook/renameNotebook with a notebook ID that is not mounted/present in the current workspace: a typo'd ID, an ID from another workspace, or a notebook already deleted. The lookup happens before any name validation, so even valid new names fail.

Common situations: Stale notebook IDs cached by plugins or external tools after the user deleted/recreated the notebook; renaming a closed or unmounted notebook whose conf is not loaded; scripts operating against the wrong workspace.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/b16ad7842be37377. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/mount.go:116

	if initializeBoxDoc {
		if _, err = ensureBoxDoc0(id); err != nil {
			treenode.RemoveBlockTreesByBoxID(id)
			sql.DeleteBoxQueue(id)
			if removeErr := filelock.Remove(boxLocalPath); nil != removeErr {
				logging.LogErrorf("remove box [%s] after initializing box document failed: %s", id, removeErr)
			}
			return "", err
		}
	}
	IncSync()
	logging.LogInfof("created box [%s]", id)
	return
}

func RenameBox(boxID, name string) (err error) {
	box := Conf.Box(boxID)
	if nil == box {
		return errors.New(Conf.Language(0))
	}

	name = normalizeBoxName(name)
	if 512 < utf8.RuneCountInString(name) {
		// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
		err = errors.New(Conf.Language(106))
		return
	}

	boxConf := box.GetConf()
	boxConf.Name = name
	box.Name = name
	if err = box.SaveConf(boxConf); err != nil {
		logging.LogErrorf("save box conf [%s] failed: %s", boxID, err)
		return
	}
	if err = renameBoxDoc(boxID, name); err != nil {
		logging.LogErrorf("rename box document [box=%s] failed: %s", boxID, err)

View on GitHub (pinned to afa823b6b4)