siyuan-note/siyuan · warning

106

106

Error message

Conf.Language(106)

What it means

Thrown by model.createBox when the normalized notebook name exceeds 512 Unicode characters (runes). SiYuan enforces a hard cap of 512 runes on notebook and document names (issue #6299), both to protect filesystem path limits and UI rendering. The message is localized via Conf.Language(106): "Maximum length is limited to 512 characters".

Solutions

  1. Truncate or shorten the notebook name to 512 runes or fewer before calling createNotebook
  2. If generating names programmatically, apply a rune-based truncation (utf8.RuneCountInString check), not a byte-based one
  3. Surface the localized 512-character limit in your UI validation so users cannot submit over-long names

Example fix

// before
id, err := model.CreateBox(name) // fails when name > 512 runes

// after
if utf8.RuneCountInString(name) > 512 {
    name = string([]rune(name)[:512])
}
id, err := model.CreateBox(name)
Defensive patterns

Strategy: validation

Validate before calling

name = strings.TrimSpace(name)
if utf8.RuneCountInString(name) > 512 {
    return fmt.Errorf("notebook name exceeds 512 characters (%d)", utf8.RuneCountInString(name))
}
id, err := model.CreateBox(name)

Prevention

When it happens

Trigger: POST /api/notebook/createNotebook with a "name" field whose rune count is > 512 after normalizeBoxName. Any client (frontend dialog, API script, plugin) that submits a very long notebook name hits this before the notebook is created.

Common situations: Programmatic import scripts that derive the notebook name from a long filename or book title; pasting a full sentence/paragraph into the new-notebook dialog; CJK users counting characters correctly (512 runes, not bytes) but exceeding it with generated names.

Related errors


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

Appendix: 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
		if err := b.SaveConf(c); err != nil {
			logging.LogErrorf("save box conf [%s] failed: %s", b.ID, err)
		}
	}

	id = ast.NewNodeID()
	boxLocalPath := filepath.Join(util.DataDir, id)

View on GitHub (pinned to afa823b6b4)