{"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":2325,"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":2307,"sourceCodeEnd":2343,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/file.go#L2307-L2343","documentation":"validateCreateDoc (kernel/model/file.go:2325) requires the BASENAME of the target path to be a valid tree ID: util.GetTreeID(baseName) must be non-empty, i.e. the file must be named like \"20240101120000-abcd123.sy\" (14-digit timestamp + 6+ alphanumeric ID). If the base carries no such ID, creation fails with Conf.Language(16). Beware: the English text of Language(16) is \"Untitled\", which looks like a default-title message but actually means \"the path's document ID is missing/malformed\" — a frequent misdiagnosis.","triggerScenarios":"POST /api/filetree/createDocWithMd with path=\"/notes/mypage.sy\" or \"/notes/mypage\" (no ID component); any createDoc call where the client supplied a human filename instead of a generated <time><rand> ID. Note a bare \"/x.sy\" also trips this before the hidden-file check.","commonSituations":"New API users assuming slug-style paths like normal note apps; converting external filenames to SiYuan paths without an ID step; docs/examples that show path as freeform.","solutions":["Generate the path in SiYuan ID form: /<parent>/<yyyyMMddHHmmss>-<random6+.sy, e.g. 20260101120000-a1b2c3d.sy","In Go use the same generator as the kernel (util time + random ID helpers); in JS build it manually from a 14-digit UTC-local timestamp plus 6 random [0-9a-z] chars","If the parent folder is the notebook root, path is \"/<id>.sy\"; for a sub-doc use \"/<parentID>/<childID>.sy\" where parentID matches the existing parent document ID"],"exampleFix":"// before\nfetchPost('/api/filetree/createDocWithMd', {notebook, path: '/my-note.sy', markdown}) // \"Untitled\" error\n\n// after\nconst ts = new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14)\nconst rand = Math.random().toString(36).slice(2, 9)\nfetchPost('/api/filetree/createDocWithMd', {notebook, path: `/${ts}-${rand}.sy`, markdown})","handlingStrategy":"validation","validationCode":"// Verify the basename carries a SiYuan tree ID before creating\nfunc pathHasTreeID(p string) bool {\n\treturn \"\" != util.GetTreeID(strings.TrimSpace(path.Base(p)))\n}","typeGuard":"func isValidCreatePath(p string) bool {\n\tbase := strings.TrimSpace(path.Base(p))\n\treturn \"\" != util.GetTreeID(base) && !strings.HasPrefix(base, \".\")\n}","tryCatchPattern":null,"preventionTips":["Always synthesize paths as /<parentID>/<14-digit-timestamp>-<random>.sy","Do not map external slugs/filenames 1:1 to SiYuan paths; put them in the title IAL instead","Know that Language(16) 'Untitled' from a create call means bad path ID, not an empty-title problem"],"tags":["siyuan","create-doc","path-format","document-id","validation"],"backgroundTag":"invalid-path-id-format","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}