siyuan-note/siyuan · error
Untitled
Error message
Untitled
What it means
Thrown by validateCreateDoc when the path's base filename yields no valid tree ID via util.GetTreeID(baseName). Conf.Language(16) = 'Untitled'. This means the filename portion of the document path doesn't contain a parseable SiYuan block ID (the YYYYMMDDHHmmss-xxxxxx format). The function cannot proceed because the document ID is derived from the path.
Source
Thrown at kernel/model/file.go:2261
func validateCreateDoc(boxID, p, title string, titleEmpty bool) (ret *createDocValidation, err error) {
p = normalizeBoxDocPath(boxID, p)
title = normalizeDocTitle(title)
if 512 < utf8.RuneCountInString(title) {
// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
return nil, errors.New(Conf.Language(106))
}
isEmpty := false
if "" == title {
title = Conf.Language(16)
isEmpty = true
} else if titleEmpty {
isEmpty = true
}
baseName := strings.TrimSpace(path.Base(p))
if "" == util.GetTreeID(baseName) {
return nil, errors.New(Conf.Language(16))
}
if strings.HasPrefix(baseName, ".") {
return nil, errors.New(Conf.Language(13))
}
box, boxErr := getOpenedBox(boxID)
if nil != boxErr {
return nil, boxErr
}
folder := path.Dir(p)
hPath := "/" + title
if "/" != folder {
parentID := path.Base(folder)
parentTree, loadErr := LoadTreeByBlockID(parentID)
if nil != loadErr {
logging.LogErrorf("get parent tree [%s] failed", parentID)
return nil, ErrBlockNotFoundView on GitHub (pinned to 251596fc0d)
Solutions
- Generate a valid SiYuan ID using the ID-generation utility and use it as the path base name (e.g., /folder/20240101120000-abcdefg.sy).
- If you only have a title, let the kernel generate the ID — pass an appropriate path constructed from the generated ID.
- Pre-validate: ensure util.GetTreeID(path.Base(p)) returns a non-empty string before calling create functions.
- For API consumers, use the create-with-markdown endpoint that auto-generates IDs if you don't supply one.
Example fix
// before
p := "/notes/my-document.sy"
err := model.ValidateCreateDoc(boxID, p, title)
// after
id := util.GetTreeID(path.Base(p))
if id == "" {
// generate a proper SiYuan ID for the path
newID := util.NewNodeID() // or the kernel's ID generator
p = path.Join(path.Dir(p), newID+".sy")
}
err := model.ValidateCreateDoc(boxID, p, title) Defensive patterns
Strategy: validation
Validate before calling
// Pre-check: ensure path base name yields a valid tree ID
baseName := strings.TrimSpace(path.Base(p))
if util.GetTreeID(baseName) == "" {
// generate a valid SiYuan ID for the path
newID := util.NewNodeID()
p = path.Join(path.Dir(p), newID+".sy")
} Type guard
func hasValidTreeID(p string) bool {
baseName := strings.TrimSpace(path.Base(p))
return util.GetTreeID(baseName) != ""
} Prevention
- Always use a SiYuan-format ID (YYYYMMDDHHmmss-xxxxxx) as the path base name.
- Generate IDs with the kernel's ID utility rather than constructing human-readable filenames.
- Validate util.GetTreeID(path.Base(p)) before calling create functions.
When it happens
Trigger: Calling create/validate functions with a path whose base name is not a valid SiYuan ID format. For example, path='/folder/mydoc.sy' instead of '/folder/20240101120000-abcdefg.sy'. The GetTreeID function extracts the ID suffix; if it returns empty, the path is malformed.
Common situations: A programmatic caller constructs a path with a human-readable filename instead of a SiYuan-format ID. A migration script creates paths without generating proper IDs. The path was manually built without using util.GetTreeID or the ID-generation utility.
Related errors
- Cannot create a file starting with .
- Duplicated filename
- custom emoji name must not be empty
- invalid path
- path must start with /
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/d5c2a8ad2e272d90.
Report an issue: GitHub.