siyuan-note/siyuan · error
Maximum length is limited to 512 characters
Error message
Maximum length is limited to 512 characters
What it means
renameDoc0 (kernel/model/file.go:2219) enforces the 512-rune cap on document titles (issue #6299). The input first passes normalizeDocTitle (strips '/', removes invalid characters, trims), then utf8.RuneCountInString(title) must be <= 512 or the call fails with Conf.Language(106). Counting is per Unicode rune, not per byte — a CJK title fails at 513 characters while a byte-count check would have allowed far fewer, and ZWJ emoji sequences count as multiple runes.
Solutions
- Truncate the title to 512 runes (count runes, not bytes/UTF-16 units) before calling the API
- Validate in UI input fields with a rune counter so users see the limit before submitting
- For generated titles, cap the source text earlier (e.g. first 500 runes + ellipsis) to leave room for normalization differences
Example fix
// before
fetchPost('/api/filetree/renameDoc', {notebook, path, title: autoSummary}) // may exceed 512 runes
// after
const title = Array.from(autoSummary).slice(0, 512).join('') // rune-safe truncation
fetchPost('/api/filetree/renameDoc', {notebook, path, title}) Defensive patterns
Strategy: validation
Validate before calling
// Rune-accurate title clamp before renameDoc
func clampTitle(title string) string {
r := []rune(normalizeDocTitle(title))
if 512 < len(r) {
return string(r[:512])
}
return string(r)
} Prevention
- Count runes, not bytes or UTF-16 code units — CJK and ZWJ emoji sequences shift the count
- Normalize (strip '/' and invalid chars) before measuring, because the kernel measures after normalization
- Cap auto-generated titles at generation time (first N runes of source text)
When it happens
Trigger: POST /api/filetree/renameDoc / renameDocByID with a title longer than 512 runes after normalization; typically programmatic titles (auto-generated summaries, concatenated lists, pasted blobs) rather than hand-typed names.
Common situations: Plugins that derive titles from document content; imports where the first line becomes the title; automated pipelines naming docs from long strings.
Related errors
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/b393cf7d443e642d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/file.go:2219
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 afa823b6b4)