siyuan-note/siyuan · error

Conf.Language(106)

Error message

Conf.Language(106)

What it means

After normalizing the title, renameDoc0 enforces the documented maximum: a document title longer than 512 UTF-8 runes is rejected with errors.New(Conf.Language(106)), "Maximum length is limited to 512 characters" (issue #6299). The limit exists because the title becomes the filename and path components must stay portable.

Solutions

  1. Truncate the title to 512 UTF-8 runes (e.g. Array.from(title).slice(0, 512).join("")) before calling renameDoc.
  2. Use the first N characters plus an ellipsis when deriving titles from content.
  3. Sanitize input in the UI/form to cap the title field length before submission.

Example fix

// before
await fetchPost("/api/filetree/renameDoc", { notebook, path, title: longHeading });
// after
const title = Array.from(longHeading).slice(0, 512).join("");
await fetchPost("/api/filetree/renameDoc", { notebook, path, title });
Defensive patterns

Strategy: validation

Validate before calling

const truncate512 = s => Array.from(s).slice(0, 512).join("");
title = truncate512(title);

Prevention

When it happens

Trigger: Calling /api/filetree/renameDoc (or renameDoc0) with a title whose utf8.RuneCountInString exceeds 512; renaming a doc whose title was programmatically set from long content (e.g. first heading text or a pasted paragraph).

Common situations: Scripts generating doc titles from long headings, URLs, or AI output; importing content that converts a very long line into a document title; users pasting an entire paragraph as the doc name via API-driven tooling.

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@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/e6856971831d9adb. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/file.go:2215

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

	FlushTxQueue()
	luteEngine := util.NewLute()
	tree, err := filesys.LoadTree(box.ID, p, luteEngine)
	if err != nil {
		return
	}

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

	var isEmpty bool
	if "" == title {
		title = Conf.language(16)
		isEmpty = true
	}
	// 先规范化输入得到实际会存储的标题,再与旧标题比较
	titleChanged := tree.Root.IALAttr("title") != title

	var emptyAttrUpdated bool
	if titleChanged {
		tree.HPath = path.Join(path.Dir(tree.HPath), title)
		tree.Root.SetIALAttr("title", title)
	}

	// 按需同步“无标题”标记(仅更新 IAL,不触发子树重命名等)
	isTitleEmpty := tree.Root.IALAttr(NodeAttrTitleEmpty) == "true"

View on GitHub (pinned to 9f775e8a12)