{"record":{"id":"c84a01380a399ed4","repo":"siyuan-note/siyuan","slug":"conf-language-106-c84a01","errorCode":null,"errorMessage":"Conf.Language(106)","messagePattern":"Conf\\.Language\\(106\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/mount.go","lineNumber":68,"sourceCode":"func getOpenedBox(boxID string) (ret *Box, err error) {\n\tif ret = Conf.Box(boxID); nil != ret {\n\t\treturn\n\t}\n\tif nil != Conf.GetBox(boxID) {\n\t\treturn nil, ErrBoxClosed\n\t}\n\treturn nil, ErrBoxNotFound\n}\n\nfunc CreateBox(name string) (id string, err error) {\n\treturn createBox(name, true)\n}\n\nfunc createBox(name string, initializeBoxDoc bool) (id string, err error) {\n\tname = normalizeBoxName(name)\n\tif 512 < utf8.RuneCountInString(name) {\n\t\t// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299\n\t\terr = errors.New(Conf.Language(106))\n\t\treturn\n\t}\n\tFlushTxQueue()\n\n\tcreateDocLock.Lock()\n\tdefer createDocLock.Unlock()\n\n\tboxes, _ := ListNotebooks()\n\tfor i, b := range boxes {\n\t\tc := b.GetConf()\n\t\tc.Sort = i + 1\n\t\tb.Sort = c.Sort\n\t\tif err := b.SaveConf(c); err != nil {\n\t\t\tlogging.LogErrorf(\"save box conf [%s] failed: %s\", b.ID, err)\n\t\t}\n\t}\n\n\tid = ast.NewNodeID()","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/mount.go#L50-L86","documentation":"createBox (kernel/model/mount.go) enforces a maximum notebook name length of 512 UTF-8 runes (per issue #6299). When the supplied name exceeds it, the kernel returns the localized message for language key 106 (\"name too long\" style message) to the caller — createEncryptedBox and CreateBox propagate it to the createNotebook API handler.","triggerScenarios":"Calling the /api/notebook/createNotebook endpoint (or createEncryptedBox for encrypted notebooks) with a notebook name longer than 512 Unicode code points — measured in runes, so emoji/CJK count once each but long pasted titles easily exceed the limit.","commonSituations":"Automated notebook creation scripts using a full document title or path as the notebook name; pasting long headings from other tools; tests generating very long random names.","solutions":["Truncate or shorten the notebook name to at most 512 runes before calling createNotebook.","Use utf8.RuneCountInString (Go) or [...name].length (JS) to check the length, not byte length.","Handle the localized error in the API client and prompt the user for a shorter name."],"exampleFix":"// before\ncreateNotebook(longDocumentTitle); // may exceed 512 runes\n// after\nconst name = [...longDocumentTitle].length > 512\n  ? [...longDocumentTitle].slice(0, 512).join(\"\")\n  : longDocumentTitle;\ncreateNotebook(name);","handlingStrategy":"validation","validationCode":"function isValidNotebookName(name) {\n  return typeof name === \"string\" && [...name].length > 0 && [...name].length <= 512;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await createNotebook(name);\n} catch (e) {\n  if (isLocalizedKernelError(e)) showUserMessage(e.msg); // key 106: name too long\n}","preventionTips":["Check [...name].length <= 512 before calling createNotebook.","Truncate programmatically generated names from titles/paths.","Count runes (code points), not bytes, for names containing emoji or CJK."],"tags":["notebook","name-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-14T00:17:10.932Z"}