{"record":{"id":"d5c2a8ad2e272d90","repo":"siyuan-note/siyuan","slug":"untitled","errorCode":null,"errorMessage":"Untitled","messagePattern":"Untitled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2261,"sourceCode":"func validateCreateDoc(boxID, p, title string, titleEmpty bool) (ret *createDocValidation, err error) {\n\tp = normalizeBoxDocPath(boxID, p)\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 nil, errors.New(Conf.Language(106))\n\t}\n\n\tisEmpty := false\n\tif \"\" == title {\n\t\ttitle = Conf.Language(16)\n\t\tisEmpty = true\n\t} else if titleEmpty {\n\t\tisEmpty = true\n\t}\n\n\tbaseName := strings.TrimSpace(path.Base(p))\n\tif \"\" == util.GetTreeID(baseName) {\n\t\treturn nil, errors.New(Conf.Language(16))\n\t}\n\tif strings.HasPrefix(baseName, \".\") {\n\t\treturn nil, errors.New(Conf.Language(13))\n\t}\n\n\tbox, boxErr := getOpenedBox(boxID)\n\tif nil != boxErr {\n\t\treturn nil, boxErr\n\t}\n\n\tfolder := path.Dir(p)\n\thPath := \"/\" + title\n\tif \"/\" != folder {\n\t\tparentID := path.Base(folder)\n\t\tparentTree, loadErr := LoadTreeByBlockID(parentID)\n\t\tif nil != loadErr {\n\t\t\tlogging.LogErrorf(\"get parent tree [%s] failed\", parentID)\n\t\t\treturn nil, ErrBlockNotFound","sourceCodeStart":2243,"sourceCodeEnd":2279,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/file.go#L2243-L2279","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\np := \"/notes/my-document.sy\"\nerr := model.ValidateCreateDoc(boxID, p, title)\n\n// after\nid := util.GetTreeID(path.Base(p))\nif id == \"\" {\n    // generate a proper SiYuan ID for the path\n    newID := util.NewNodeID() // or the kernel's ID generator\n    p = path.Join(path.Dir(p), newID+\".sy\")\n}\nerr := model.ValidateCreateDoc(boxID, p, title)","handlingStrategy":"validation","validationCode":"// Pre-check: ensure path base name yields a valid tree ID\nbaseName := strings.TrimSpace(path.Base(p))\nif util.GetTreeID(baseName) == \"\" {\n    // generate a valid SiYuan ID for the path\n    newID := util.NewNodeID()\n    p = path.Join(path.Dir(p), newID+\".sy\")\n}","typeGuard":"func hasValidTreeID(p string) bool {\n    baseName := strings.TrimSpace(path.Base(p))\n    return util.GetTreeID(baseName) != \"\"\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["create","validation","path","tree-id","untitled"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}