siyuan-note/siyuan · error
106
106
Error message
Maximum length is limited to 512 characters
What it means
In createBox (the body behind CreateBox), if utf8.RuneCountInString(name) > 512 the function returns errors.New(Conf.Language(106)) = 'Maximum length is limited to 512 characters'. The limit is by Unicode rune count, not byte count, and applies after normalizeBoxName. Reference: siyuan-note/siyuan#6299.
Source
Thrown at kernel/model/mount.go:68
func getOpenedBox(boxID string) (ret *Box, err error) {
if ret = Conf.Box(boxID); nil != ret {
return
}
if nil != Conf.GetBox(boxID) {
return nil, ErrBoxClosed
}
return nil, ErrBoxNotFound
}
func CreateBox(name string) (id string, err error) {
return createBox(name, true)
}
func createBox(name string, initializeBoxDoc bool) (id string, err error) {
name = normalizeBoxName(name)
if 512 < utf8.RuneCountInString(name) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
err = errors.New(Conf.Language(106))
return
}
FlushTxQueue()
createDocLock.Lock()
defer createDocLock.Unlock()
boxes, _ := ListNotebooks()
for i, b := range boxes {
c := b.GetConf()
c.Sort = i + 1
if err := b.SaveConf(c); err != nil {
logging.LogErrorf("save box conf [%s] failed: %s", b.ID, err)
}
}
id = ast.NewNodeID()
boxLocalPath := filepath.Join(util.DataDir, id)View on GitHub (pinned to 251596fc0d)
Solutions
- Truncate or prompt for a shorter name before calling CreateBox: keep to ≤512 Unicode code points.
- Validate with utf8.RuneCountInString(name) <= 512 in your caller and surface a friendly error.
- Strip excessive whitespace/normalise via the same logic the kernel uses if you want to maximise usable length.
Example fix
// before
name := longExternalString
id, err := model.CreateBox(name) // err == Language(106)
// after
const maxNameRunes = 512
if utf8.RuneCountInString(name) > maxNameRunes {
name = string([]rune(name)[:maxNameRunes])
}
id, err := model.CreateBox(name) Defensive patterns
Strategy: validation
Validate before calling
const maxNotebookNameRunes = 512
func validNotebookName(name string) error {
if utf8.RuneCountInString(name) > maxNotebookNameRunes {
return fmt.Errorf("name exceeds %d runes", maxNotebookNameRunes)
}
return nil
} Type guard
null
Try / catch
null
Prevention
- Clamp user input to ≤512 runes before CreateBox/RenameBox.
- Validate at the UI/API boundary, not just at the kernel call.
When it happens
Trigger: Calling CreateBox (or any internal path through createBox) with a name longer than 512 runes. This is the notebook-creation API; the same 512-rune ceiling is enforced on RenameBox (796) and document titles elsewhere.
Common situations: Programmatic creation with an unbounded user input (e.g. importing a folder name as a notebook); paste of a very long string; a script that derives the notebook name from a long path or metadata field.
Related errors
- 0
- invalid notebook ID
- can not remove [%s] caused by it is a reserved file
- invalid box id
- path belongs to encrypted notebook [%s]: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/7f69f1bf09d927d6.
Report an issue: GitHub.