siyuan-note/siyuan · error

Conf.Language(106)

Error message

Conf.Language(106)

What it means

renameDoc0 normalizes the new doc title and rejects it when it exceeds 512 runes, throwing errors.New(Conf.Language(106)) which reads "Maximum length is limited to 512 characters". The limit exists to bound path lengths and keep document names safe across filesystems (issue #6299). The rename is aborted before any file is touched.

Source

Thrown at kernel/model/file.go:2182

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 8641553a1f)

Solutions

  1. Shorten the title to at most 512 characters before calling the API
  2. Trim/derive the title from a fixed prefix of the desired text
  3. In plugin UI, add a maxlength=512 check on the rename input

Example fix

// before
await fetchPost('/api/filetree/renameDoc', {box, path: p, title: veryLongTitle});
// after
const title = veryLongTitle.length > 512 ? veryLongTitle.slice(0, 512) : veryLongTitle;
await fetchPost('/api/filetree/renameDoc', {box, path: p, title});
Defensive patterns

Strategy: validation

Validate before calling

function enforceTitleLimit(title, max = 512) {
  const runes = [...title];
  return runes.length > max ? runes.slice(0, max).join('') : title;
}

Try / catch

try {
  await fetchPost('/api/filetree/renameDoc', {box, path, title});
} catch (e) {
  if (String(e).includes('512')) {
    await fetchPost('/api/filetree/renameDoc', {box, path, title: [...title].slice(0, 512).join('')});
  }
}

Prevention

When it happens

Trigger: POST /api/filetree/renameDoc (or RenameDoc) where utf8.RuneCountInString(normalizeDocTitle(title)) > 512.

Common situations: Renaming a document with pasted long content; programmatic renames that use block text as the title; importing Markdown with very long H1 headings mapped to doc names; non-ASCII titles where users underestimate rune counts.

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/e6856971831d9adb. Report an issue: GitHub.