{"record":{"id":"e6856971831d9adb","repo":"siyuan-note/siyuan","slug":"conf-language-106","errorCode":null,"errorMessage":"Conf.Language(106)","messagePattern":"Conf\\.Language\\(106\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2182,"sourceCode":"\nfunc renameDoc0(boxID, p, title string) (err error) {\n\tbox := Conf.Box(boxID)\n\tif nil == box {\n\t\terr = errors.New(Conf.Language(0))\n\t\treturn\n\t}\n\n\tFlushTxQueue()\n\tluteEngine := util.NewLute()\n\ttree, err := filesys.LoadTree(box.ID, p, luteEngine)\n\tif err != nil {\n\t\treturn\n\t}\n\n\ttitle = normalizeDocTitle(title)\n\tif 512 < utf8.RuneCountInString(title) {\n\t\t// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299\n\t\treturn errors.New(Conf.Language(106))\n\t}\n\n\tvar isEmpty bool\n\tif \"\" == title {\n\t\ttitle = Conf.language(16)\n\t\tisEmpty = true\n\t}\n\t// 先规范化输入得到实际会存储的标题，再与旧标题比较\n\ttitleChanged := tree.Root.IALAttr(\"title\") != title\n\n\tvar emptyAttrUpdated bool\n\tif titleChanged {\n\t\ttree.HPath = path.Join(path.Dir(tree.HPath), title)\n\t\ttree.Root.SetIALAttr(\"title\", title)\n\t}\n\n\t// 按需同步“无标题”标记（仅更新 IAL，不触发子树重命名等）\n\tisTitleEmpty := tree.Root.IALAttr(NodeAttrTitleEmpty) == \"true\"","sourceCodeStart":2164,"sourceCodeEnd":2200,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/file.go#L2164-L2200","documentation":"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.","triggerScenarios":"POST /api/filetree/renameDoc (or RenameDoc) where utf8.RuneCountInString(normalizeDocTitle(title)) > 512.","commonSituations":"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.","solutions":["Shorten the title to at most 512 characters before calling the API","Trim/derive the title from a fixed prefix of the desired text","In plugin UI, add a maxlength=512 check on the rename input"],"exampleFix":"// before\nawait fetchPost('/api/filetree/renameDoc', {box, path: p, title: veryLongTitle});\n// after\nconst title = veryLongTitle.length > 512 ? veryLongTitle.slice(0, 512) : veryLongTitle;\nawait fetchPost('/api/filetree/renameDoc', {box, path: p, title});","handlingStrategy":"validation","validationCode":"function enforceTitleLimit(title, max = 512) {\n  const runes = [...title];\n  return runes.length > max ? runes.slice(0, max).join('') : title;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await fetchPost('/api/filetree/renameDoc', {box, path, title});\n} catch (e) {\n  if (String(e).includes('512')) {\n    await fetchPost('/api/filetree/renameDoc', {box, path, title: [...title].slice(0, 512).join('')});\n  }\n}","preventionTips":["Count characters as Unicode runes, not UTF-16 units","Truncate titles derived from user content or external sources","Add maxlength attributes to rename/create inputs"],"tags":["siyuan","kernel","rename","title-length","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}