siyuan-note/siyuan · error

Conf.Language(106)

Error message

Conf.Language(106)

What it means

createBox (kernel/model/mount.go) enforces a maximum notebook name length of 512 UTF-8 runes (per issue #6299). When the supplied name exceeds it, the kernel returns the localized message for language key 106 ("name too long" style message) to the caller — createEncryptedBox and CreateBox propagate it to the createNotebook API handler.

Source

Thrown at kernel/model/mount.go:68

func getOpenedBox(boxID string) (ret *Box, err error) {
	if ret = Conf.Box(boxID); nil != ret {
		return
	}
	if nil != Conf.GetBox(boxID) {
		return nil, ErrBoxClosed
	}
	return nil, ErrBoxNotFound
}

func CreateBox(name string) (id string, err error) {
	return createBox(name, true)
}

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

	createDocLock.Lock()
	defer createDocLock.Unlock()

	boxes, _ := ListNotebooks()
	for i, b := range boxes {
		c := b.GetConf()
		c.Sort = i + 1
		b.Sort = c.Sort
		if err := b.SaveConf(c); err != nil {
			logging.LogErrorf("save box conf [%s] failed: %s", b.ID, err)
		}
	}

	id = ast.NewNodeID()

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Truncate or shorten the notebook name to at most 512 runes before calling createNotebook.
  2. Use utf8.RuneCountInString (Go) or [...name].length (JS) to check the length, not byte length.
  3. Handle the localized error in the API client and prompt the user for a shorter name.

Example fix

// before
createNotebook(longDocumentTitle); // may exceed 512 runes
// after
const name = [...longDocumentTitle].length > 512
  ? [...longDocumentTitle].slice(0, 512).join("")
  : longDocumentTitle;
createNotebook(name);
Defensive patterns

Strategy: validation

Validate before calling

function isValidNotebookName(name) {
  return typeof name === "string" && [...name].length > 0 && [...name].length <= 512;
}

Try / catch

try {
  await createNotebook(name);
} catch (e) {
  if (isLocalizedKernelError(e)) showUserMessage(e.msg); // key 106: name too long
}

Prevention

When it happens

Trigger: Calling the /api/notebook/createNotebook endpoint (or createEncryptedBox for encrypted notebooks) with a notebook name longer than 512 Unicode code points — measured in runes, so emoji/CJK count once each but long pasted titles easily exceed the limit.

Common situations: Automated notebook creation scripts using a full document title or path as the notebook name; pasting long headings from other tools; tests generating very long random names.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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