{"record":{"id":"e6856971831d9adb","repo":"siyuan-note/siyuan","slug":"conf-language-106","errorCode":null,"errorMessage":"Conf.Language(106)","messagePattern":"Conf\\.Language\\(106\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2215,"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":2197,"sourceCodeEnd":2233,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L2197-L2233","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Truncate the title to 512 UTF-8 runes (e.g. Array.from(title).slice(0, 512).join(\"\")) before calling renameDoc.","Use the first N characters plus an ellipsis when deriving titles from content.","Sanitize input in the UI/form to cap the title field length before submission."],"exampleFix":"// before\nawait fetchPost(\"/api/filetree/renameDoc\", { notebook, path, title: longHeading });\n// after\nconst title = Array.from(longHeading).slice(0, 512).join(\"\");\nawait fetchPost(\"/api/filetree/renameDoc\", { notebook, path, title });","handlingStrategy":"validation","validationCode":"const truncate512 = s => Array.from(s).slice(0, 512).join(\"\");\ntitle = truncate512(title);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap title inputs at 512 UTF-8 runes in UI forms and scripts.","Use Array.from (codepoint-aware), not .length, when measuring.","Derive auto-generated titles from bounded slices of content."],"tags":["kernel","rename","title-length","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}