siyuan-note/siyuan · warning
Maximum length is limited to 512 characters
Error message
Maximum length is limited to 512 characters
What it means
Thrown by renameDoc0 when the new document title exceeds 512 Unicode runes (not bytes). Conf.Language(106) = 'Maximum length is limited to 512 characters'. The check uses utf8.RuneCountInString(title) after normalizeDocTitle, so the limit applies to the normalized title. This addresses issue #6299 which capped excessively long names.
Source
Thrown at kernel/model/file.go:2155
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 251596fc0d)
Solutions
- Truncate the title to 512 runes before calling RenameDoc: title = substring by rune count.
- In UI code, enforce a maxlength on the rename input field.
- For programmatic callers, check utf8.RuneCountInString(title) > 512 and truncate or warn the user.
- If a longer title is essential, store the full text in a custom IAL attribute instead of the document title.
Example fix
// before
err := model.RenameDoc(boxID, p, title)
// after
if runes := utf8.RuneCountInString(title); runes > 512 {
runified := []rune(title)
title = string(runified[:512])
}
err := model.RenameDoc(boxID, p, title) Defensive patterns
Strategy: validation
Validate before calling
// Pre-check: enforce 512-rune limit on title
title = model.NormalizeDocTitle(title)
if utf8.RuneCountInString(title) > 512 {
title = string([]rune(title)[:512])
} Type guard
func titleWithinLimit(title string) bool {
return utf8.RuneCountInString(title) <= 512
} Prevention
- Check utf8.RuneCountInString(title) before calling RenameDoc.
- Truncate titles to 512 runes (not bytes — multi-byte characters matter).
- Enforce maxlength on rename input fields in UI code.
- Store excessively long text in a custom IAL attribute if needed.
When it happens
Trigger: Calling RenameDoc(boxID, p, title) where the normalized title has more than 512 runes. This happens when a user pastes a very long string, or a programmatic rename uses auto-generated titles from content that exceeds the limit.
Common situations: A user renames a document using a full paragraph or very long heading. An import or sync operation generates a title from document content that exceeds 512 runes. A plugin auto-titles from the first block without truncation.
Related errors
- Do not include symbols \ / : * ? " ' < > |
- 106
- 0
- Failed to update agent session permission
- Agent capability name and description are required
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/b393cf7d443e642d.
Report an issue: GitHub.