{"record":{"id":"dbaea746d46f6e27","repo":"siyuan-note/siyuan","slug":"conf-language-16","errorCode":null,"errorMessage":"Conf.Language(16)","messagePattern":"Conf\\.Language\\(16\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2306,"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":2288,"sourceCodeEnd":2324,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L2288-L2324","documentation":"validateCreateDoc derives the new doc's ID-bearing basename from the requested path via strings.TrimSpace(path.Base(p)) and runs util.GetTreeID on it. If that yields an empty string the path is not a usable document path, and the kernel returns errors.New(Conf.Language(16)) — literally the string \"Untitled\" — as the error. Practically it means the client passed a path whose basename cannot carry a doc ID (e.g. empty path or a bare '/').","triggerScenarios":"Calling /api/filetree/createDoc with an empty or root-only path value ('' or '/'); a client that builds the path by joining an empty parent ID with the title; passing a path missing the required <timestamp>-<random> ID segment format.","commonSituations":"Plugin code where parentPath is undefined/empty and string concatenation produced '/'; API scripts testing createDoc with minimal params and omitting path; UI state where the selected parent doc ID was not yet loaded.","solutions":["Pass a well-formed path ending in a valid doc-ID basename, e.g. '/20240101120000-abcdefg' (parent doc path) — the kernel then generates the child ID.","If you have no parent, create the doc at the notebook root with path set to a newly generated ID via /api/filetree/createDocWithMd or generate an ID client-side.","Check for empty/undefined path values in the calling code before the request.","Use /api/filetree/getDocTree to pick a real parent path."],"exampleFix":"// before\nawait fetchPost(\"/api/filetree/createDoc\", { notebook, path: parentPath || \"\", title });\n// after\nconst p = parentPath || \"/\" + newDocID(); // valid '<yyMMddHHmmss>-<rand>' basename\nawait fetchPost(\"/api/filetree/createDoc\", { notebook, path: p, title });","handlingStrategy":"validation","validationCode":"function hasValidDocBasename(p) {\n  const base = p.split(\"/\").filter(Boolean).pop() || \"\";\n  return /^\\d{14}-[a-z0-9]{7}$/.test(base);\n}\nif (!hasValidDocBasename(p)) throw new Error(\"path needs a valid doc-ID basename\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass an empty or root-only path to createDoc.","Verify parentPath is defined before building the request path.","Pick parent paths from the doc tree API rather than manual strings."],"tags":["kernel","create-doc","path-format","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}