{"record":{"id":"7f69f1bf09d927d6","repo":"siyuan-note/siyuan","slug":"106","errorCode":"106","errorMessage":"Conf.Language(106)","messagePattern":"Conf\\.Language\\(106\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","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\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()\n\tboxLocalPath := filepath.Join(util.DataDir, id)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/mount.go#L50-L86","documentation":"Thrown by model.createBox when the normalized notebook name exceeds 512 Unicode characters (runes). SiYuan enforces a hard cap of 512 runes on notebook and document names (issue #6299), both to protect filesystem path limits and UI rendering. The message is localized via Conf.Language(106): \"Maximum length is limited to 512 characters\".","triggerScenarios":"POST /api/notebook/createNotebook with a \"name\" field whose rune count is > 512 after normalizeBoxName. Any client (frontend dialog, API script, plugin) that submits a very long notebook name hits this before the notebook is created.","commonSituations":"Programmatic import scripts that derive the notebook name from a long filename or book title; pasting a full sentence/paragraph into the new-notebook dialog; CJK users counting characters correctly (512 runes, not bytes) but exceeding it with generated names.","solutions":["Truncate or shorten the notebook name to 512 runes or fewer before calling createNotebook","If generating names programmatically, apply a rune-based truncation (utf8.RuneCountInString check), not a byte-based one","Surface the localized 512-character limit in your UI validation so users cannot submit over-long names"],"exampleFix":"// before\nid, err := model.CreateBox(name) // fails when name > 512 runes\n\n// after\nif utf8.RuneCountInString(name) > 512 {\n    name = string([]rune(name)[:512])\n}\nid, err := model.CreateBox(name)","handlingStrategy":"validation","validationCode":"name = strings.TrimSpace(name)\nif utf8.RuneCountInString(name) > 512 {\n    return fmt.Errorf(\"notebook name exceeds 512 characters (%d)\", utf8.RuneCountInString(name))\n}\nid, err := model.CreateBox(name)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enforce a 512-rune input maxlength in any UI that creates notebook names","Use utf8.RuneCountInString, never len(string), when checking length for CJK text","In batch importers, validate and truncate generated names before submission"],"tags":["notebook","validation","length-limit","i18n","siyuan"],"backgroundTag":"name-length-limit-exceeded","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}